【问题标题】:Redirect all requests to non-www https将所有请求重定向到非 www https
【发布时间】:2015-09-14 02:15:23
【问题描述】:

我已经在 SO 上搜索了我的问题的解决方案,但没有一个答案对我有用。

这就是我想要实现的目标:

Redirect all

http://example.com -> https://example.com
http://www.example.com -> https://example.com
https://www.example.com -> https://example.com

基本上,我希望将访问的任何形式的域重定向到 非 WWW https (https://example.com)

【问题讨论】:

标签: .htaccess redirect url-rewriting url-redirection


【解决方案1】:

你可以在你的.htaccess中使用:

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

【讨论】:

  • 同样的老问题:ERR_TOO_MANY_REDIRECTS
  • 与我的代码无关,它在您的配置或具有其他规则的 htaccess 中
  • 这是 htaccess 中唯一的代码。这是标题现在的样子:HTTP/1.1 400 Bad Request => Server => cloudflare-nginx Date => Sun, 13 Sep 2015 18:29:47 GMT Content-Type => text/html Content-Length => 177 Connection => close
  • cloudflare 配置有问题?正如我所说,我认为这是配置的问题。
猜你喜欢
  • 1970-01-01
  • 2015-09-30
  • 2015-02-25
  • 2014-02-13
  • 2015-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-08
相关资源
最近更新 更多