全部,
以下是我如何使用 Apache 和 Config.php 文件重写 URL,以免从浏览器触发“非 SSL 内容警告”。我仍然在我的模板中使用 {path} 和 {stylesheet} 变量,因为它们太好了,不能放弃:)
在 Apache 的 htaccess 文件中:
# Set an Apache 'site_url' variable to http when accessed via http:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ - [E=site_url:http://mysite.com]
# Set Apache 'site_url' variable to https when accessed via https
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ - [E=site_url:https://mysite.com]
然后在system/expressionengine/config.php中
将以下两行添加到您的代码中(确保您没有在配置文件的其他位置设置这些变量)
$config['base_url'] = $_SERVER["site_url"];
$config['site_url'] = $_SERVER["site_url"];
据我了解,site_url 变量是 EE 用于 EE 中的 {stylesheets} 和 {paths} 的。
谚语“最后一件事”:
如果您仍然收到非 SSL 警告,只需查看源代码并在源代码中搜索“http://”。这些是罪魁祸首。它们是未使用 base_url/site_url 变量设置的硬编码链接。
您需要在您的帖子/模板/变量/sn-ps 中找到这些 http 调用,并用简单的 // 替换这些调用。
所以打电话给
http://example.com/some_file.html
现在应该是这样的:
//example.com/some_file.html.
这适用于绝对和相对 URL。
对于您设置为 EE 文件上传目录的路径也是如此。确保将这些目录的 url 更改为如下所示
//example.com/path/to/your/upload/directory
瞧,你应该很高兴:)