Server Fault is a question and answer site for system and network 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'm having trouble redirecting: to

I've currently got this and its not achieving the result I need and I'm not sure why:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

I basically want to redirect everything to

I appreciate any help.

share|improve this question
What result is it achieving? – Ladadadada Mar 23 '12 at 15:24
@Ladadadada because there is no certificate for you get an SSL warning, I was hoping the rewrite would overcome this? – Abs Mar 23 '12 at 15:32
up vote 2 down vote accepted

Based on your comment you're trying to redirect in order to avoid a mis-matched URL SSL warning in the browser window. This cannot be done, as the redirect happens after the SSL handshake (because it uses a Location: response header to a request that won't be sent until the SSL handshake occurs and is accepted by the user).

Your best approach is:

  • Split into a separate VirtualHost and use mod_alias as @HampusLi suggested
  • Purchase another certificate for and apply it to this VirtualHost

Alternatively, you could get a SAN (Subject Alternate Name) certificate that works for both and

share|improve this answer

You dont need mod_rewrite for this, you can use the much more lightweight built in module mod_alias with this simple syntax under the http vhost:

Redirect permanent /
share|improve this answer
Of course he means – gparent Mar 23 '12 at 15:30

Your Answer


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

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