I've been lucky enough in the past when I have to migrate a site from HTTP to HTTPS and install a SSL Cert that I my host does it and everything just works.
I'm working with a host now where I think I will need to be more hands on.
I'm using Wordpress on a Mysql and Apache stack. What would be the proper way to migrate this. Doing a search and replace via the database and then redirects via the .htaccess file?
Currently, I have "https://example.com" working. However, what is the proper way to handle the redirects from www to non-www for both the http and https to "https://example.com". There are Wordpress plugins that "force" SSL but I have heard these can do unexpected things.
Thanks
First, I'll explain the procedure without the use of a .htaccess file: Assuming that you have your wordpress site in place say "http://example.com"
Then go to Settings » Permalink and click Save to ensure that all post links are working fine.
Install this plugin Search & Replace and activate. This plugin is supposed to help in fixing images and broken links by updating paths without you having to write code; it's pretty self explanatory.
And yes I agree with you that WP Force SSL plugin does wonders to a website, I've tried it and I learn't a lesson the hard way, but still I'll try it out. At this point you'll have your "https://example.com" working perfectly
Secondly, I'll explain doing the same procedure without using any plugin. My assumption is same as above.
Don't leave your database yet, we need to do a search and replace in MySQL using SQL Query. I've listed just a few of things needed to be replaced in the SQL query below
NB: Depending on the tables you have, its always good to do a search and replace per table
To redirect from http to https we'll use
.htaccess
file. Try the following with mod_rewrite in your.htaccess
fileor any of the various approaches given at
http://www.askapache.com/htaccess/http-https-rewriterule-redirect.html
You can also solve this from within PHP in case your provider has disabled
.htaccess
(which is unlikely since you asked for it, but anyway)Until this point with both methods https should be working well.
Then, to redirect non-www to www, use the following code directly below RewriteEngine On in the .htaccess file:
For www to non-www, use:
If you're on a Windows IIS server, the above code won't work for you. I can share the procedure if need be.