2011-11-02 26 views
0

嗨,大家好,我非常感谢你,因为我从这里得到了几个解决方案,就像我希望我能为我当前的问题获得解决方案。如何在.htaccess中重写URL

URL是这样

www.xyz.com/c73-Graphic-Desgin?resultpage=2&aid=1 
在URL “73” “2” “1” 是值

我试图重写它像下面.htaccess文件

,但它不会工作...

RewriteEngine On 
RewriteRule ^c(.+)-(.+)-(.+)?resultpage=(.+)&aid=(.+)/?$ template.php?cid=$1&resultpage=$4&aid=$5&search=yes 

请帮我解决这个问题,在此先感谢...

我.htacces s文件

RewriteEngine On 

#RewriteRule ^article/(.*)?$ article.php?aid=$1 
#RewriteRule ^knowledge_base/([0-9]+)/(.*)?$ knowledge_base.php?p=$1&cid=$2 
RewriteRule ^(.*)-article?$ article_detail.php?artid=$1 

RewriteRule ^t([0-9]+)-(.+)/?$ temlate_detail.php?tid=$1 

RewriteRule ^c([0-9]+)-sc([0-9]+)-(.+)/?$ templates.php?cid=$1&&scid=$2 
RewriteRule ^c([0-9]{1,2})[a-zA-Z-]+?resultPage=([0-9]+)&aid=([0-9]+)$ templates.php?cid=$1 


RewriteRule ^ac([0-9]+)-(.+)/?$ articles.php?cid=$1 
RewriteRule ^p-(.*)$ pages.php?pageid=$1 

#For PHP files: 

RewriteCond %{REQUEST_FILENAME} !-s 
RewriteRule ^(index|about|faq|freelancers|articles|contact|affiliates|login|forgot_password|change_password|cart|order_view|checkout|checkout_response|success|downloads|order_detail)(/.*)?$ $1.php 
#php_value display_errors Off 
#php_value upload_max_filesize 2000M 
#php_value post_max_size 2000M 
Options All -Indexes 

回答

0

你的正则表达式是错误的..你可以使用类似这样的东西。

^c([0-9]{1,2})[a-zA-Z-]+?resultPage=([0-9]+)&aid=([0-9]+)$ //put here whatever u like to with $1, $2, $3 and $4 
+0

感谢您的快速回复.. 我试图这样 重写规则^ C([0-9] {1,2})[A-ZA-Z - ] + resultPage =([0 -9] +)&aid =([0-9] +)$ templates.php?cid = $ 5 但它也给错误:(​​ – rkaartikeyan

+0

什么是错误? –

+0

https://www.magiktemplates.com/c73 -Graphic-Desgin?resultpage = 2&aid = 1 看到链接...其给出的错误..先生 – rkaartikeyan