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 have a website that I don't want to be used over HTTP. How can I make Apache redirect all HTTP requests to https://mysite?

share|improve this question
This seems to be what you are looking for:… – Aaron Copley Mar 21 '11 at 22:43
up vote 3 down vote accepted

In the config for your port 80 VirtualHost:

RewriteEngine on
RewriteRule ^.*$ https://mysite/ [R=301]

If you want to keep the url path that was entered, you can do this instead:

RewriteEngine on
RewriteRule ^(.*)$ https://mysite$1 [R=301]
share|improve this answer
What does [R=301] mean? – pyon Mar 21 '11 at 22:39
It means to send a 301 status code with the redirect, which means "permanent". The default, when you don't specify (using just [R]) is to send a 302 status code, which indicates "found" - the real-world difference is debatable, but sending a 301 is the "correct" way to do it. – Shane Madden Mar 21 '11 at 22:48
By the way, sorry for the delay, I thought I had already accepted your answer. – pyon Mar 21 '11 at 22:52

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.