更新时间:2023-02-23 09:38:18
尝试:
RewriteCond %{THE_REQUEST} \?[^\ ]+
RewriteRule (.*) /$1? [R=301,L] #remove query string
您需要根据实际请求进行匹配,因为您正在使用以下规则构建查询字符串:
You need to match against the actual request because you're building a query string with these rules:
# To internally rewrite directories as query string
RewriteRule ^([^/=]+)=([^/]*)(/(.+))?\/?$ /$4?$1=$2 [N,QSA]
RewriteRule ^([^/=]+)/([^/=]+)(/(.+))?\/?$ /$4?$1=$2 [N,QSA]
RewriteRule ^([^/=]+)(/(.+))?\/?$ /$3?$1 [N,QSA]
当这些规则循环时,%{QUERY_STRING}
变量将包含内容,而您的规则将破坏它们.如果您与实际请求匹配,则您的重写不会受到影响.
When these rules loop around, the %{QUERY_STRING}
variable will have stuff in it and your rules will clobber them. If you match against the actual request, your rewrites won't get affected.