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?

link|improve this question

This seems to be what you are looking for: stackoverflow.com/questions/1816119/… – Aaron Copley Mar 21 '11 at 22:43
feedback

1 Answer

up vote 2 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]
link|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
feedback

Your Answer

 
or
required, but never shown

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