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 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: stackoverflow.com/questions/1816119/… –  Aaron Copley Mar 21 '11 at 22:43
add comment

1 Answer

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? –  Eduardo León Mar 21 '11 at 22:39
1  
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. –  Eduardo León Mar 21 '11 at 22:52
add comment

Your Answer

 
discard

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.