How to redirect url requests to https?

I’ve searched far and wide for a solution to this and I am sure it’s simple but I simply couldn’t find a solution.

This is the regular wordpress redirect code:

Read More
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

How do I make it so that this will always route the url request to https://?

Note: The reason this is posted here and not on any other SO site is that I thought there might be a catch when it comes to WP.

BTW, I put the same question on ServerFault and got a big On Hold because “I did not try to solve this myself”.

Related posts

1 comment

  1. This really belongs on ServerFault, StackOverflow or Webmasters…

    But basically, you need to add something along these lines before the WP rules begin:

    RewriteEngine on
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
    

Comments are closed.