【问题标题】:Too many redirects when using "www"-URL (https redirection is activ)使用“www”-URL 时重定向过多(启用 https 重定向)
【发布时间】:2019-04-22 18:24:14
【问题描述】:

我有一个 Wordpress 安装。我的 URL 在 Wordpress 中配置为“https://example.com”。由于我只想提供安全连接,所有http://example.com 请求都会自动重定向到 https 域,并在我的 .htaccess 中使用以下代码:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

此代码 sn-p 在标准 Wordpress sn-p 之前。 它有效,但我不能在“example.com”之前使用 www。所以谷歌浏览器给了我一个“ERR_TOO_MANY_REDIRECTS”错误。

感谢您的帮助。非常感谢!

【问题讨论】:

    标签: wordpress .htaccess redirect https


    【解决方案1】:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    在您的 .htacess 文件上使用它。让我知道它是否有效

    【讨论】:

      猜你喜欢
      • 2018-07-14
      • 2016-10-14
      • 2012-02-06
      • 2018-07-25
      • 1970-01-01
      • 2018-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多