MODX Evolution 将所有网络流量发送到 https

MODX Evolution 将所有网络流量发送到 https

可能重复:
HTTPS 站点的 Apache 重写规则和 DNS 设置

我刚刚为网站添加了 SSL 证书,该网站应该只在 https 上响应。访问 http 的人应该被发送到 https。

我希望这个问题可以通过 .htaccess 解决

如果用户输入www.domain.no,则应该自动https://www.domain.no。如果管理员也访问管理器,则必须发生这种情况,因为如果管理器使用 http 登录,缓存将被清除,并且 https 无法正确显示(看起来缺少 css)。访问管理器的方式如下:www.domain.no/manager

我的 .htaccess 文件现在的情况如下:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# Fix Apache internal dummy connections from breaking [(site_url)] cache
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]

# Rewrite domain.no -> www.domain.no -- used with SEO Strict URLs plugin
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.no [NC]
RewriteRule (.*) https://www.domain.no/$1 [R=301,L]

答案1

更新:解决方案是在原始 .htaccess 文件后添加此内容:

RewriteCond %{SERVER_PORT} !=443
RewriteRule (.*) https://www.domain.no/$1 [R=301,L]

相关内容