【问题标题】:.htaccess http to https redirect loop issue.htaccess http 到 https 重定向循环问题
【发布时间】:2014-11-27 07:52:13
【问题描述】:

当用户在浏览器中输入http://example.com 时,我试图将他们重定向到https://example.com。我正在使用 .htaceess 来实现重定向。问题是在下面添加 .htaccess 到我的网站后,浏览器(chrome)显示 This pages have a redirect loop 。这是我的 .htaccess 文件

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{HTTPS} off
 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 RewriteCond %{HTTP_HOST} !^www\.
 RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

请给我建议解决方案

【问题讨论】:

  • 你的 Apache 版本是多少?
  • 它在wordpress中吗?如果是这样,请检查 wp_options 表中的主页链接。
  • 核心 PHP 站点。我也试过@Helping Hands 回答。但不工作

标签: php apache .htaccess mod-rewrite


【解决方案1】:

用户下面的代码:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

【讨论】:

    猜你喜欢
    • 2014-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-30
    相关资源
    最近更新 更多