WordPress Redirect All HTTP requests to HTTPS via .htaccess

I see, when you enter a link to your page other than your home, example:

  • http://www.michaelcropper.co.uk/contact-me
  • www.michaelcropper.co.uk/contact-me
  • michaelcropper.co.uk/contact-me

If https:// is not in the prefix, the HTTP link loads instead. Add the following into your .htaccess in between the <IfModule mod_rewrite.c> tag:

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]

If there were no additional modifications done to your .htaccess, it should look like the following:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Rewrite HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
# END WordPress

Let me know how it goes.

Leave a Comment

error code: 523