客户端只是想测试站点而不将域指向新服务器。我们只想在 port80 (HTTP) 中测试站点,因为他们还没有购买 SSL。
所以网站建立在http://<ip-address>,我们正在ip用来测试它。
但问题是,所有的主题(css/js 文件)都是通过 HTTPS 加载的。我们需要禁用它并仅通过 HTTP 加载这些文件。
到目前为止我尝试过的对我不起作用的东西
RewriteEngine On
RewriteCond %{HTTP} !=on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Run Code Online (Sandbox Code Playgroud)
wp-config.php
define('FORCE_SSL_ADMIN', true);
但不幸的是,这不起作用。
问题是所有 css 都在 HTTPS 中加载,但是当您尝试使用 http 在浏览器中搜索时,这些文件存在
有很多事情可能会导致这种情况,因此您可以尝试很多事情 - 我在下面列出了我能想到的很多事情。您已经做了一些,但为了完整起见,我将它们包括在此处,以防其他人正在搜索相同的问题。
1. 在 wp-config.php 中设置 WP_CONTENT_URL
您WP_CONTENT_URL可能正在使用 HTTPS。由于问题在于包含您的主题文件,因此这是我建议检查的第一件事。
尝试将其添加到 wp-config.php 以强制网站在包含 wp-content 文件夹时使用 HTTP:
define( 'WP_CONTENT_URL', 'http://www.www.example.com/wp-content' );
Run Code Online (Sandbox Code Playgroud)
2. 在 wp-config.php 中设置 WP_HOME 和 WP_SITEURL
将wp-config.php 中的WP_HOME和设置WP_SITEURL为使用 HTTP。这将覆盖 WP Settings 中设置的任何内容。
define('WP_HOME','http://www.example.com');
define('WP_SITEURL','http://www.example.com');
Run Code Online (Sandbox Code Playgroud)
您还可以通过查询 wp_options 表并查找 siteurl 和 home 值来确认数据库中的值,正如您已经尝试过的那样。
3.在.htaccess中将HTTPS重定向到HTTP
我知道您已经这样做了,但是您可以通过检查 HTTPSon而不是 HTTP来尝试它not off。(另请注意 - 302重定向,因为这不是永久性的!)
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
Run Code Online (Sandbox Code Playgroud)
4. WP 数据库的硬编码 URL
WP writes the full URL to the database, so there could be instances of urls using HTTPS in the db. You could check each table directly in the database, but I find the plugin "Better Search Replace" quicker and easier to use. You can do a "dry run" to search for instances of "https://www.example.com". If it finds any, you can use the plugin to replace them all (but as always, make sure you do a db backup first before making any changes directly to your db!!)
Better Search Replace plugin on wordpress.org
5. Plugins
Some plugins might be trying to force SSL. There are the obvious ones like Really Simple SSL, but other plugins can also do this, such as security & optimisation plugins - I know iThemes Security does.
If all else fails, try disabling the plugins to check.
6. Hardcoded URLs in theme files or plugin files
It is unlikely with commercial themes & plugins, but it is possible that HTTPS is hard-coded into the theme files. Do a full search or try disabling the plugins and changing the theme to a default WP theme to check.
7. Caching
Your browser, server, caching plugins, minimizer plugins (for CSS & JS) might have HTTPS in the cache (Unlikely in your case, but I'll mention it anyway). Even other less obvious plugins can have caches too, such as gallery plugins.
Clear all your caches including your browser, turn off caching plugins, etc.
You could also try adding this try adding the following to wp-config.php
define( 'WP_CACHE', false );
Run Code Online (Sandbox Code Playgroud)
8. Admin
Make sure you are not forcing SSL for the admin area - add/change the following line in wp-config.php
define('FORCE_SSL_ADMIN', false);
Run Code Online (Sandbox Code Playgroud)
I've run into this problem for similar reasons, and if the first 4 steps don't work I find it's usually a caching issue.
I hope that helps, there a lot of things you can try, and if that doesn't fix it I'm out of ideas!!
| 归档时间: |
|
| 查看次数: |
9670 次 |
| 最近记录: |