我想改变#34;热门"到最受欢迎的"在以下网址
http://www.site.com/projects?page=12&sort=popular
我认为这样可行:
RewriteRule ^projects?page=([0-9]+)&sort=popular$ http://www.site.com/projects?page=$1&sort=most-popular [L,R=301]
但它似乎没有重定向。有人能发现我做错了什么吗?我应该逃避什么吗?
答案 0 :(得分:2)
您无法在RewriteRule中访问查询字符串。你需要在RewriteCond中捕获它:
RewriteCond %{QUERY_STRING} ^page=([0-9]+)&sort=popular$
RewriteRule ^projects$ http://www.site.com/projects?page=%1&sort=most-popular [L,R=301]