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
?
1 Answer
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]
-
-
1It 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. Mar 21, 2011 at 22:48 -
By the way, sorry for the delay, I thought I had already accepted your answer. Mar 21, 2011 at 22:52