2

I'm working on a messy customer project. To debug it, I would like to work on it on localhost. I'm using Wampserver.

This is what I did :

1 - I made a virtualhost

httpd-vhosts.conf

<VirtualHost *:80>
    ServerName devfoo.pro
    DocumentRoot "c:/path/to/project/src/www"
    <Directory  "c:/path/to/project/src/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

2 - I renamed the file .htaccess to _.htaccess

At that point when I run the page, there is still a redirection from http://devfoo.pro to https://devfoo.pro.

Notice : If I rename the plugin really-simple-ssl to _really-simple-ssl, the page redirect to the online website.

So... how can I import a WordPress project on localhost and deactivate the https protocol properly ? (Keeping the https on localhost is so messy! I never manage to simulate https on a local server with or without documentation, tutorials etc... )

1
  • 2
    you are looking for the wrong solution. development enviroment should match that of production as much as possible. Using a different protocol sounds like the wrong way to go. If the certificate can not be utilized on your PC, ask your client to create a development enviroment for you on his servers. Commented Mar 16, 2018 at 3:18

2 Answers 2

1

I also had this experience with chrome and firefox, they switch http to https and did not find a way to overcome it, so i used internet explorer in that windows machine.
I don't think you can have ssl on localhost or an ip address, i guess you know it as you used devfoo.pro. SSL certificate could be generated only for fully qualified domain names.

So, you will need to buy a certificate to have things working, out of the box. Easy and "secure".
Or you can self sign one for your self, following a tutorial :-). Might be difficult and you will need to accept it in your browser or os.
Or better (at least for me), use this website. It will self sign a certificate for a provided domain.

0

to remove https on an install, you can do a find and replace on the local database, I found wpcli is the easiest way:

wp search-replace 'https://example.com' 'http://example.com'
wp search-replace 'https://www.example.com' 'http://www.example.com'

you can also do a find+replace with a normal .sql. be mindful for serialized strings in the _options table, they often break, but if you know it's broken and why it's not hard to fix.

beyond that:

  • look for plugins like "force https" and make sure they're removed

  • look in wp-config.php and make sure there's no hard coded HTTPS rule in there (sometimes force_ssl, sometimes, site_url, etc.)

  • the .htaccess renaming was a good move, but all that needs to be taken out of there is any http->https rule.

1
  • 1
    there are two big holes on this scheme. 1. The assumption that search & replace on the DB will work, and that there is no hardcoded url in the code. 2 browsers have different security models for https, so your ability to debug some of the possibly JS and CSS problems will be reduced. Commented Mar 16, 2018 at 3:26

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.