且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

的.htaccess mod_rewrite的:重写查询字符串为路径

更新时间:2023-01-08 09:38:24

要避免递归,你应该检查的请求线,而不是的如%{QUERY_STRING} 可能已经被另一个规则已经改变的查询字符串:

To avoid recursion, you should check the request line instead as the query string in %{QUERY_STRING} may already have been changed by another rule:

RewriteCond %{THE_REQUEST} ^GET\ /\?(([^&\s]*&)*)tag=([^&\s]+)&?([^\s]*)
RewriteRule ^(.*)$ /tag/%3?%1%4 [L,R=301]

然后你可以重写请求回内部没有矛盾:

Then you can rewrite that requests back internally without conflicts:

RewriteRule ^tag/(.*) index.php?tag=$1 [L]