【发布时间】:2013-02-24 18:34:28
【问题描述】:
我在 WordPress 上的网站上添加了 SSL 证书。当我将以下代码添加到 htaccess 文件时,我丢失了导航菜单中的下拉菜单,并且在各种浏览器中发生了不同的事情。
这是我添加到 htacces 以强制站点从 http 到 https 的代码:
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://{SERVER_NAME}%{REQUEST_URI} [R,L]
这就是 htaccess 文件现在的样子:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
如果能够让网站顶部的菜单导航再次正常工作,我将不胜感激。
【问题讨论】:
-
可能您的菜单与
http://链接,需要https://? -
所有浏览器都会出现这种情况吗?您的菜单很可能是通过 http 协议引用的,但是当您通过 https 请求站点时……您会遇到在 https 协议上引用的不安全 (http) 项目的安全冲突。例如,如果您通过 JavaScript 包含菜单:example.com,请尝试使用与协议无关的格式://www.example.com,以便它适用于 https 和 http。
-
@user2150689 你有changed the site URL 使用HTTPS 协议吗?我还建议您将 https 重写规则 above
RewriteBase指令,感觉不对:) -
那将是低于而不是高于lol
-
您好,感谢您的 cmets。我将网站网址从 http 更改为 https。 @LookitsPuck 你去哪里修复 javascript 以使其不可知...我是这方面的新手。
标签: wordpress .htaccess http mod-rewrite