我如何使用重写来更改:
/?tag=foo
致:
/标签/foo
我尝试过:
RewriteCond %{QUERY_STRING} ^tag=(.+)$
RewriteRule ^(.*)$ http://www.example.com/tag/$1 [L]
但是没有成功。
最佳答案
尝试以下操作:
RewriteCond %{QUERY_STRING} ^tag=(.+)$
RewriteRule ^(.*)$ http://www.example.com/tag/%1 [L]
通常使用重写来达到相反的效果。您确定不想执行以下操作吗?
RewriteRule ^tag/(.+)$ index.php?tag=$1 [L]
关于.htaccess mod_rewrite : rewriting querystring to path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1217981/