我需要从
重定向网址website.com/search.php?city=india&keyword=laptop
要 website.com/search/india/laptop
如何使用htaccess执行此操作
在我的htaccess
中显示代码Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)(/)?$ search.php?city=$1&keyword=$2
答案 0 :(得分:0)
您可以在根.htaccess文件中使用此规则:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+search\.php\?city=([^&]+)&keyword=([^\s&]+) [NC]
RewriteRule ^ /search/%1/%2? [R=301,L,NE]
RewriteRule ^search/([\w-]+)/([\w-]+)/?$ /search.php?city=$1&keyword=$2 [L,QSA]