1

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

1 Answer 1

3

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]
3
  • What does [R=301] mean?
    – isekaijin
    Mar 21, 2011 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. Mar 21, 2011 at 22:48
  • By the way, sorry for the delay, I thought I had already accepted your answer.
    – isekaijin
    Mar 21, 2011 at 22:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .