3

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:

<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".

  • Search on Stack Overflow. It would be closed as duplicate there, that’s why haven’t migrated it. – fuxia Nov 13 '13 at 10:49
  • @toscho I searched SO I couldn't find anything that explains what Denis explained. All I could find were how to move http to https when talking about the root domain not a different url and not something that already contains a RewriteRule. – hitautodestruct Nov 13 '13 at 10:51
3

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]
  • Thank you very much for this! I tried on server fault and got put on hold.. I wasn't sure if this needed something special because it's wordpress. – hitautodestruct Nov 13 '13 at 10:14
  • 1
    I've implemented your solution and I am getting "too many redirects" – SkyHiRider Apr 14 '14 at 0:14
  • Does seem to work for me. Here is the snippet # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Just added the https always rule inside the WP snippet after RewriteEngine On – rhand May 18 '15 at 10:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.