Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to redirect the following instances to https://www.mydomain.com;

I have the following in my .htaccess already, but this only redirects mydomain.com to https://www.mydomain.com;

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

Grateful if anyone could perhaps tell me what I need to add. Thank you.

share|improve this question

migrated from stackoverflow.com Nov 12 '11 at 8:59

This question came from our site for professional and enthusiast programmers.

    
Perfect. Thank you. :D –  Arpanet Sep 26 '11 at 21:28

1 Answer 1

up vote 1 down vote accepted

Remove the second RewriteCond so you filter ONLY on the https status, and not anything to do with the requested host. That'll make it an unconditional redirect, regardless of how the site was requested

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.