我们正在从一个重要来源接收流量,但他们使用/?在它的末尾。我尝试使用我们的 .htaccess 中的条目进行重定向,但这不起作用:
Redirect /? http://[domain]
RewriteEngine on
RewriteBase /
我也试过反斜杠:
Redirect /\? http://[domain]
RewriteEngine on
RewriteBase /
有人知道如何让它工作吗?
最佳答案
您不需要 Redirect
指令,因为在这种情况下需要更高级的 mod_rewrite
。
试试这个规则:
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+([^?]*)\?\s [NC]
RewriteRule ^ /%1? [R=302,L]
关于regex - [领域]/?使用 .htaccess 重定向到 [域],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32763063/