【问题标题】:.htaccess url rewrite from http to https.htaccess url 从 http 重写为 https
【发布时间】:2014-07-18 00:15:56
【问题描述】:

我最近刚刚使用 SSL 证书更新了我们的网站。我们正在重写 URL,当输入 http://example.comhttp://www.example.com 时,它会被转换为 https://example.com

但是我们发现很多访问者都有链接到特定页面或文件的收藏夹,而 .htaccess 翻译失败。

例如点击收藏夹时 http://example.com/themes/default/images/emailLogo.png 然后将访问者定向到 https://example.comthemes/default/images/emailLogo.png(注意 URL 中缺少的斜杠)

这是我的 .htaccess 文件信息

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule ^images/.+$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} !(example\.org|example-me.org|example.me)$
RewriteRule ^(.*)$ https://example.org/$1 [R=302,L]

RewriteRule ^http://example.org/images/(.*) https://example.org/images/$1 [R]
RewriteRule ^http://www.example.org/images/(.*) https://example.org/images/$1 [R]
RewriteRule ^(.+)\.html$ /bootstrap.php?file=$1.html [L,NC,QSA]
RewriteRule ^(.+)\.phtml$ /bootstrap.php?file=$1.html [L,NC,QSA]
</IfModule>

ErrorDocument 404 /404.php

DirectoryIndex index.html index.php

【问题讨论】:

    标签: apache .htaccess mod-rewrite ssl


    【解决方案1】:

    如果其他人偶然发现这篇文章,我会发现问题。 apache 配置中有一个重定向,将所有端口 80 请求重定向到 https://example.com

    我把它改成了https://example.com/

    (* 注意斜杠 *)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 2015-01-10
      • 2012-07-23
      • 1970-01-01
      • 2014-03-04
      • 2014-12-09
      • 2021-01-30
      相关资源
      最近更新 更多