【发布时间】:2014-07-09 22:51:07
【问题描述】:
我已经设置了一个 .htccess 文件来将 www 重定向到非 www 并删除尾部斜杠。我还必须确保business.domain.com 也将(301)重定向到domain.com。除了重定向business.domain.com,其他规则都有效。
<IfModule mod_rewrite.c>
RewriteEngine On
# redirect to non-www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# redirect business subdomain to no subdomain
RewriteCond %{HTTP_HOST} ^business\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# redirect non-trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
任何想法为什么第二个条件/规则没有生效?
【问题讨论】:
-
愚蠢的是,我刚刚意识到业务子目录中存在一个 .htaccess 文件。将其重命名为 .htaccess_,现在可以使用了。
标签: wordpress apache .htaccess mod-rewrite redirect