如何将所有流量从www.domain.com/page重定向到domain.com/page?
我需要禁止流量的网页地址,包括万维网。原因是我有一个SSL证书,它只适用于非www网址。如果用户试图访问https://www.domain.com,则会得到一个证书错误。
发布于 2013-09-10 19:17:55
取消Drupal在web根目录中附带的.htaccess文件中的第93和第94行。
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewiteRule ^ http://%1%{REQUEST_URI} [L,R=301]编辑:如果证书需要https,请编辑第二行:
RewiteRule ^ https://%1%{REQUEST_URI} [L,R=301]发布于 2014-10-20 10:52:01
这就是如何在Drupal 7中实现这一点,编辑您的.htaccess
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} .
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]https://drupal.stackexchange.com/questions/85253
复制相似问题