我最近刚刚使用 SSL 证书更新了我们的网站。我们正在重写 URL,并在输入 http://example.com 时或 http://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 配置中有一个重定向,将所有端口 80 请求重定向到 https://example.com
我将其更改为 https://example.com/
(* 注意尾部的斜杠 *)
关于apache - .htaccess url 从 http 重写为 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23917284/