WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]

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

share|improve this question

closed as off-topic by Denis de Bernardy, toscho Nov 13 '13 at 8:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions should be specific to WordPress within defined scope (merely happening in its context, such as generic PHP/JS/HTML/CSS, is insufficient). Might be better asked at Stack Overflow or other appropriate site of Stack Exchange network." – toscho
If this question can be reworded to fit the rules in the help center, please edit the question.

Search on Stack Overflow. It would be closed as duplicate there, that’s why haven’t migrated it. – toscho 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
up vote 3 down vote accepted

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]
share|improve this answer
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
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.