如何在 Wordpress 中禁用 HTTPS 并将 HTTPS 重定向到 HTTP? [英] How to disable HTTPS and redirect HTTPS to HTTP in Wordpress?

查看:219
本文介绍了如何在 Wordpress 中禁用 HTTPS 并将 HTTPS 重定向到 HTTP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户端只是想测试站点而不将域指向新服务器.我们只想在端口 80 (HTTP) 中测试站点,因为他们还没有购买 SSL.

The client just wanted to test the site without pointing the domain to the new server. We just want to test the site in port80 (HTTP) only, since they haven't the purchased SSL yet.

所以网站设置在http://,我们使用ip来测试它.

So the website is set up at http://<ip-address> and we are using ip to test it.

但问题是,所有的主题(css/js 文件)都是通过 HTTPS 加载的.我们需要禁用它并仅通过 HTTP 加载这些文件.

But the problem is, all the themes (css/js files) are loaded over HTTPS. We need to disable it and load these files over HTTP only.

到目前为止我尝试过的方法对我不起作用

What I have tried so far that didn't work for me

  1. htaccess

       RewriteEngine On
       RewriteCond %{HTTP} !=on
       RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

  1. _wp_options 表

  1. wp-config.php

  1. wp-config.php

define('FORCE_SSL_ADMIN', true);

  1. 常规设置

但不幸的是,这不起作用.

But unfortunately this doesn't work.

问题是所有 css 都是在 HTTPS 中加载的,但是当您尝试使用 http 在浏览器中搜索时这些文件存在

The problem is all css are loaded in HTTPS but these files exists when you try them to search in browser using http

推荐答案

导致这种情况的原因有很多,因此您可以尝试很多事情 - 我在下面列出了我能想到的很多.您已经做了一些,但为了完整起见,我将它们包括在此处,以防其他人正在搜索相同的问题.

There are a quite few things that could cause this, so there are lots of things you can try - I've listed as many I can think of below. You have already done some, but I'm including them here for completeness, in case someone else is searching with the same issue.

1.在 wp-config.php 中设置 WP_CONTENT_URL

您的 WP_CONTENT_URL 可能正在使用 HTTPS.由于问题在于包含您的主题文件,因此这是我建议检查的第一件事.

Your WP_CONTENT_URL might be using HTTPS. As the issue is with including your theme files, this is the first thing I'd suggest checking out.

尝试将其添加到 wp-config.php 以强制网站在包含 wp-content 文件夹时使用 HTTP:

Try adding this to wp-config.php to force the website to use HTTP when including from the wp-content folder:

define( 'WP_CONTENT_URL', 'http://www.www.example.com/wp-content' );

<小时>

2.在 wp-config.php 中设置 WP_HOME 和 WP_SITEURL

在 wp-config.php 中设置 WP_HOMEWP_SITEURL 以使用 HTTP.这将覆盖在 WP 设置中设置的任何内容.

Set the WP_HOME and WP_SITEURL in wp-config.php to use HTTP. This will override whatever was set in the WP Settings.

define('WP_HOME','http://www.example.com');
define('WP_SITEURL','http://www.example.com');

您还可以通过查询 wp_options 表并查找 siteurl 和 home 值来确认数据库中的值,正如您已经尝试过的那样.

You can also confirm what the values are in the database by querying the wp_options table and look for siteurl and home values, as you have already tried.

3.将 HTTPS 重定向到 .htaccess 中的 HTTP

我知道您已经这样做了,但是您可以通过检查 HTTPS on 而不是 HTTP 是否not off 来尝试.(另请注意 - 302 重定向,因为这不是永久性的!)

I know you have this done already, but you could try it by checking if HTTPS on rather than HTTP is not off. (Also note - 302 redirect because this is not permanent!)

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE] 

<小时>

4.WP 数据库中的硬编码 URL

WP 将完整 URL 写入数据库,因此数据库中可能存在使用 HTTPS 的 URL 实例.您可以直接在数据库中检查每个表,但我发现插件更好的搜索替换"更快、更易于使用.您可以进行试运行"以搜索https://www.example.com"的实例.如果找到,您可以使用该插件将它们全部替换(但与往常一样,请确保在直接对您的数据库进行任何更改之前先进行数据库备份!!)

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!!)

更好的搜索替换 wordpress.org 上的插件

5.插件

某些插件可能会尝试强制使用 SSL.有很明显的,比如Really Simple SSL,但其他插件也可以做到这一点,比如security &优化插件 - 我知道 iThemes Security 可以.

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.主题文件或插件文件中的硬编码 URL

商业主题不太可能插件,但 HTTPS 有可能被硬编码到主题文件中.进行完整搜索或尝试禁用插件并将主题更改为默认 WP 主题进行检查.

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.缓存

您的浏览器、服务器、缓存插件、最小化插件(用于 CSS 和 JS)可能在缓存中有 HTTPS(在您的情况下不太可能,但无论如何我都会提到).甚至其他不太明显的插件也可以有缓存,例如画廊插件.

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.

您也可以尝试添加此尝试将以下内容添加到 wp-config.php

You could also try adding this try adding the following to wp-config.php

define( 'WP_CACHE', false );

<小时>

8.管理员

确保您没有为管理区域强制使用 SSL - 在 wp-config.php 中添加/更改以下行

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);

<小时>

由于类似的原因,我遇到了这个问题,如果前 4 个步骤不起作用,我发现这通常是缓存问题.


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!!

这篇关于如何在 Wordpress 中禁用 HTTPS 并将 HTTPS 重定向到 HTTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆