Select Page

Force HTTP to HTTPS Using .htaccess File

I have recently upgraded my site to use a SSL certificate to make sure my blog uses https on all pages. I will be creating a guide on how to complete this shortly. After upgrading I noticed that my site was still allowing users to visit and it was not forwarding to the address. I have resolved this by adding the following code to the .htaccess file in the root of my website directory. This will also add a 301 redirect on the http:// to the https:// page, this is very good for SEO purposes.


# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
# END WordPress
When you have added this to the file you should clear your website cache and try accessing the website again. You’ll now notice that this forwards to the https:// address as per the below screenshot!
Redirect To HTTPS - Force HTTP to HTTPS Using .htaccess File
Thanks for reading, stay tuned for the guide on how to migrate your WordPress site to https!

Pin It on Pinterest

Share This