例如,我需要根据查询基本参数重定向 Apache
https://example.com/?ampostpreserve=01902018
我需要重定向到 https://example.com .. 我试过
RewriteEngine On RewriteCond %{QUERY_STRING} ^ampostpreserv$ RewriteRule (.*) https://example.com [R=301,L]
但似乎不起作用..任何解决方案
谢谢下摆
最佳答案
您似乎只想删除查询字符串? QSD 参数正是这样做的。以下版本适用于每个调用的 URL。
RewriteEngine On
RewriteCond %{QUERY_STRING} .+
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [QSD,L,R=301]
这是 example.com 的特定版本和上面的查询字符串:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^ampostpreserve
RewriteRule .* https://example.com [QSD,L,R=301]
关于linux - Apache 在查询时重定向到主 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54310913/