需要这样的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]
不工作
答案 0 :(得分:0)
也许你想要它反过来
RewriteRule ^/tags/(.*)$ /tags/index.php?tag=$1
仅当输入已包含查询字符串时,才使用带有测试字符串QUERY_STRING
的 RewriteCond
。如果要将某个URL重写到另一个URL,只需将所需的查询字符串附加到目标URL即可。