我只想重定向 WordPress 网站的主页,但前提是原始 URL 上不包含任何查询字符串。这有效:
RedirectMatch 307 ^/$ http://www.consumerenergyreport.com/ticker
...但是通过查询重定向 URL。我尝试过:
RewriteCond ! %{QUERY_STRING}
...但这似乎不适用于 RedirectMatch,只能使用 RewriteRule(如图)。
有什么想法吗?提前致谢!
最佳答案
在 .htaccess 文件中尝试此规则:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/?$ /ticker [R=307,L]
关于regex - 重定向主页,但如果存在查询字符串则不重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5813273/