2

我想转换这个网址:

http://ts.thebenamorgroup.com/g2g/category.php?cate=mens

至:

http://ts.thebenamorgroup.com/g2g/category/cate/mens/   

我有这个规则,但它不起作用:

Options +FollowSymLinks
RewriteEngine on
RewriteRule category/cate/(.*)/ category.php?cate=$1
RewriteRule category/cate/(.*) category.php?cate=$1
4

2 回答 2

2

您的重写是相反的方向。即它重写

http://ts.thebenamorgroup.com/g2g/category/cate/mens/ 

至:

http://ts.thebenamorgroup.com/g2g/category.php?cate=mens

如果你想要的是重定向

http://ts.thebenamorgroup.com/g2g/category.php?cate=mens

至:

http://ts.thebenamorgroup.com/g2g/category/cate/mens/   

然后你可以使用: -

RewriteEngine on

RewriteBase /

RewriteCond %{QUERY_STRING} cate=(\d+) [NC]
RewriteRule ^g2g/category\.php$ /g2g/category/cate/%1/ [NC,R]
于 2013-07-09T05:50:19.497 回答
1

尝试:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /g2g/

RewriteRule ^category/cate/(.+?)/?$ category.php?cate=$1 [L]

RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /g2g/category\.php\?cate=([^&\ ]+)&?([^\ ]*)
RewriteRule ^ /g2g/category/cate/%2?%3 [L,R=301]
于 2013-07-09T05:32:31.297 回答