.htaccess htaccess将规则查询字符串重写为url
我有以下网址:.htaccess htaccess将规则查询字符串重写为url,.htaccess,url-rewriting,.htaccess,Url Rewriting,我有以下网址: www.example.com/profile?id=31 我想把它重定向到: www.example.com/profile/id/31 我该怎么做 我试着用这个: RewriteCond %{QUERY_STRING} (^|&)id=31($|&) RewriteRule ^www\.example\.com/profile$ /www.example.com/profile/id/31?&%{QUERY_STRING} 但它不起作用我会选择这
www.example.com/profile?id=31
我想把它重定向到:
www.example.com/profile/id/31
我该怎么做
我试着用这个:
RewriteCond %{QUERY_STRING} (^|&)id=31($|&)
RewriteRule ^www\.example\.com/profile$ /www.example.com/profile/id/31?&%{QUERY_STRING}
但它不起作用我会选择这样的方式,如果有帮助,请告诉我:
RewriteRule ^ profile/([0-9]+)/?$ /profile?id=$1 [NC,L,QSA]
这篇文章和其他答案对它的作用进行了广泛的解释。尝试以下内容:
RewriteCond %{QUERY_STRING} ^(.+)=(.+)
RewriteRule ^(.+)$ http://www.example.com/$1/$2/$3 [R=301,L,QSD]
我使用的是匹配组,所以它将适用于给定相似模式的任何值