【发布时间】:2014-03-18 00:09:21
【问题描述】:
当我访问我的“domain.com/?”或“domain.com/?any-other-character-here”它显示我的主页,这会导致 Google 中出现重复的结果。 Web 服务器是 Apache。
我的代码是
ErrorDocument 404 domain.com/error404.html
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) domain.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} \s/+\?\s
RewriteRule ^ /? [R=301,L]
它将非 www 重定向到 www,我在其中添加了您的代码。但仍然看到 domain.com/?any-random-text 不会重定向到 404
【问题讨论】:
标签: regex apache .htaccess redirect http-status-code-301