如何编写规则query_string RewriteEngine

时间:2014-11-02 09:57:12

标签: mod-rewrite query-string

需要这样的http://example.net/tags/index.php?tag=anytag, 制作这样的http://example.net/tags/anytag

RewriteEngine On
RewriteCond %{QUERY_STRING}     ^tag=(.*)$    [NC]
RewriteRule ^tags/index.php$     /tags/$1     [NC,L,R=301]

不工作

1 个答案:

答案 0 :(得分:0)

也许你想要它反过来

RewriteRule ^/tags/(.*)$ /tags/index.php?tag=$1
仅当输入已包含查询字符串时,才使用带有测试字符串QUERY_STRING

RewriteCond。如果要将某个URL重写到另一个URL,只需将所需的查询字符串附加到目标URL即可。