301 redirect URL with variable

早过忘川 提交于 2020-01-16 12:01:49

问题


I want to use htaccess to 301 redirect (not rewrite) urls like:

brands.php?brand=Sony

to

brands/Sony

How can i do that? Appreciate your help in advance.


回答1:


So your users are entering brands.php?brand=Sony into their browser, and being redirected? If I have that correct, it's simple:

RewriteEngine On
RewriteCond %{QUERY_STRING} brand=([^&]+) [NC]
RewriteRule brands\.php brands/%1 [L,R=301]


来源:https://stackoverflow.com/questions/7796421/301-redirect-url-with-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!