首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将所有www地址重定向到非www web地址。

问将所有www地址重定向到非www web地址。
EN

Drupal用户
提问于 2013-09-10 19:07:27
回答 2查看 4.5K关注 0票数 1

如何将所有流量从www.domain.com/page重定向到domain.com/page?

我需要禁止流量的网页地址,包括万维网。原因是我有一个SSL证书,它只适用于非www网址。如果用户试图访问https://www.domain.com,则会得到一个证书错误。

EN

回答 2

Drupal用户

发布于 2013-09-10 19:17:55

取消Drupal在web根目录中附带的.htaccess文件中的第93和第94行。

代码语言:javascript
复制
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewiteRule ^ http://%1%{REQUEST_URI} [L,R=301]

编辑:如果证书需要https,请编辑第二行:

代码语言:javascript
复制
RewiteRule ^ https://%1%{REQUEST_URI} [L,R=301]
票数 6
EN

Drupal用户

发布于 2014-10-20 10:52:01

这就是如何在Drupal 7中实现这一点,编辑您的.htaccess

代码语言:javascript
复制
# 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]
票数 1
EN
页面原文内容由Drupal提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://drupal.stackexchange.com/questions/85253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档