This short article goes through the simple steps to move your WordPress website from HTTP to HTTPS yourself without using plug-ins or other tools. With the increased pressure from internet browser manufacturers to move content to a secure web, the switch is important for those wanting a higher search ranking or performing any action other than basic information.
There’s no magic involved in this move and I don’t go into details of all the things that you can do, I just show you how to get your website up and running after you have a secured certificate installed.
Make sure you take a site backup and that includes your database before starting.
So starting from where you have got your secure certificate installed, you will need to login to your admin site using your normal HTTP path. Once you have logged in, go to General in the Settings section.
Change the two URLs to the http versions. Some secure certificates allow the URL to be specified without “www” and with it but others just allow one or the other. Check this first from the details of your secure certificate purchase before setting it here.
Save and then log back in using the https version of the admin site.
Visit your new https site, you might need to re-upload certain images in your theme such as in the header or footer or in any sliders. WordPress seems to sort out any internal links within your site automatically but not the images.
For images that are in your post or page content, you can just adjust any mentions of “http://” with “https://” but you do need to be careful to include your domain name otherwise you might be linking to a site that does not have a secure certificate. What you want to do is find images with a source of https and that belong to your website. You can go through them manually looking at the “img” tags and adjusting from http to https if they reside on your site. If you are linking to images on other sites they might not have a https version available.
When I changed my site from http to https I had over 90 posts and several pages with images in them. I really didn’t fancy doing this manually so I wrote a script to do the replace for me.
UPDATE wp_posts SET `post_content` = REPLACE( `post_content` , ‘<img src=\”http://pathowe.co.uk’, ‘<img src=\”https://pathowe.co.uk’ ) WHERE `post_content` LIKE ‘%<img src=\”http://pathowe.co.uk%’;
To do this I went into phpMyAdmin and ran it directly on the WordPress database. You might have a different method of connecting to your database but the image is the script in the phpMyAdmin application. If using this script remember to change all references to my website to yours being careful not to change “http” and “https”.
Afterwards, test your site again and all should be good.
If you ever need to go back the other way then just reverse the “http” and “https” parts of the script above and re-upload the theme images after switching back the URL in the settings.
If I don’t write again beforehand then I wish you all happy festive season and fantastic 2018!