9

Just today I synchronized a development website database with a production website database.

Now, my development website gives a "404 Not Found" error. The URL starts with HTTPS, and there is a red slash through the HTTPS text. The 404 page says "The server can not find the requested page: dev.greenbee-web.com/ilaimh/wp-admin/ (port 443). Apache Server at dev.greenbee-web.com Port 443".

I did not realize that the production website uses HTTPS ( I am an employee and so I'm not the only one working on this website). This made the development website now use HTTPS, but I want it to use HTTP. I can't figure out where, in any of WordPress's configuration files, I can make the development website go back to using HTTP.

Is there some setting in wp-config that is forcing my development site to use HTTPS? If not in wp-config, where is the setting that is forcing the site to use HTTPS?

Thank you

3
  • 1
    your development and staging enviroment should always match as much as possible the production enviroment. Not using the same protocol is a very big deviation which is not even justified in any way Commented Mar 27, 2016 at 18:34
  • 1
    hello… First look in the global settings (url fields) of wordpress. After that in most cases, you have one file (and also some plugins) that can be related to your problem : in .htaccess file located in main directory of your wordpress website, you have to look after something like RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]… Also some security plugins or some "SSL" plugins can be responsible. Commented Mar 27, 2016 at 22:54
  • @MarkKaplun - this is an unacceptable answer to the question. Please explain, in detail, how I can install a valid certificate for a server on a local network with an unroutable IP, or install a valid SSL certificate on a public server for an IP address. When moving from development to live you have to change all the URLs anyway. Commented Jan 27, 2019 at 19:23

5 Answers 5

10

There are 2 things you must do.

If you are using Apache server go to .htaccess and change the Rewrite and RewriteBase engine to

RewriteEngine On

RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

If you are using Nginx something like this should work

server {
   listen 80 443;
   server_name example.com;
   # add ssl settings
   return 301 https://example.com$request_uri;
}

This would redirect the https to http

and go to the database through phpmyadmin or whatever you use go to wp_options and find and change the siteurl and home values from https://example.com to http://example.com

Clean your cache and try again. It should work without problem. If the site still asks for SSL check your wp-config.php file to see if it has this code

define('FORCE_SSL_ADMIN', true);

then change the 'true' to 'false'

Hope this helps you.

2
  • 2
    In my case it came down to your last suggestion, commenting out these lines: //define( 'FORCE_SSL_LOGIN', 1 ); //define( 'FORCE_SSL_ADMIN', 1 );
    – TARKUS
    Commented Jul 16, 2018 at 22:37
  • for IIS, what can I do to disable http? I have tried defining define('FORCE_SSL_ADMIN', true); but it did not work Commented Mar 13, 2020 at 18:14
4

There's a couple of factors here.

First of all, you might want to check the site settings in wp_options (or wp_X_options if you're in a multisite setup), especially the value of:

  • home
  • siteurl

The other tables you want to check are:

  • wp_blogs
  • wp_domain_mapping
  • wp_options
  • wp_site
  • wp_sitemeta

I don't know what sort of system you guys use to sync your dev DB with prod, but we have an SQL script we run after we clone a subset of the prod database.

UPDATE wp_dev.wp_blogs SET domain = REPLACE(domain, "https://produrl.com", "http://devurl.com");
UPDATE wp_dev.wp_domain_mapping SET domain = REPLACE(domain, "https://produrl.com", "http://devurl.com");
UPDATE wp_dev.wp_options SET option_value = REPLACE(option_value, "https://produrl.com", "http://devurl.com");
UPDATE wp_dev.wp_site SET domain = REPLACE(domain, "https://produrl.com", "http://devurl.com");
UPDATE wp_dev.wp_sitemeta SET meta_value = REPLACE(meta_value, "https://produrl.com", "http://devurl.com");

Replace wp_dev with your local database, and produrl.com and devurl.com as necessary. But notice that this changes the internal URLs from HTTPS to HTTP.

Finally, you may need to change your local WP config, and update these two settings:

define('FORCE_SSL_LOGIN', false);
define('FORCE_SSL_ADMIN', false);
0

Thank you Loic. Im using BackupBuddy to copy my active websites and restore on WAMP. One of the sites kept trying to use HTTPS. Ive been trying to install a cert on local wamp without any luck.

I did look at the directory of my locally restored site and removed the simple ssl folder.

Boom. It works now and stays on HTTP

Man that that was too easy. Thanks again.

0

If the load balancer terminates ssl (https), then wordpress will receive http traffic and redirect to https, even though the traffic to the LB is https, resulting in infinite redirect.

To solve this, I have this in my wp-config.php:

  $_SERVER['HTTPS'] = 'on';

Or slightly more complicated (for custom installs):

  if (getenv('use_ssl')) {
    $_SERVER['HTTPS'] = 'on';
  }
2
  • That's true, and there's a note about that in the WordPress docs too: Administration over SSL. There they test a common header set by the load balancer.
    – Rup
    Commented Jun 24, 2022 at 0:04
  • (I'm not sure that's exactly what this question is asking about though.)
    – Rup
    Commented Jun 24, 2022 at 0:04
-3

Your development and staging enviroment should always match as much as possible the production enviroment. Not using the same protocol is a very big deviation which is not even justified in any way.

Since it is your organization, just install the same certificate on your dev enviroment, or if it is bound to a specific IP for some reason, generate a new one for your dev enviroment.

4
  • Downvoting because this does not answer the question.
    – naomi
    Commented Feb 26, 2020 at 14:13
  • @naomi I am truly surprised that at this age when everything is HTTPS there is a suggestion that there is a point in trying to support HTTP. The only true answer is to fix the dev enviroment Commented Mar 2, 2020 at 14:07
  • 1
    The question was how to stop WP from forcing SSL. I came to it because I had this issue with local sites on my laptop.
    – naomi
    Commented Mar 2, 2020 at 15:31
  • Yes local development suffers from the use of HTTPS, but if you do not use HTTPS how do you know that your resources are loaded correctly? If, like the OP, you have the trust of the owner of the site you can ask to get his certificate and properly configure the domain and certificate on your laptop Commented Mar 3, 2020 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.