【发布时间】:2014-07-18 00:15:56
【问题描述】:
我最近刚刚使用 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 .htaccess mod-rewrite ssl