I want to force Apache to redirect all traffic through HTTPS:

# Redirect HTTP traffic to HTTPS.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://mypublicip/$1 [R=301,L]

Unfortunately, this does not work when I am trying to access my website from my local network using my Web server's private IP. How could I work around this limitation?

link|improve this question

feedback

1 Answer

up vote 2 down vote accepted

mod_rewrite supports more variables like %{HTTPS}. For your requirement %{HTTP_HOST} is the way to go.

link|improve this answer
Do you mean something like RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]? – Eduardo León Mar 22 '11 at 18:45
feedback

Your Answer

 
or
required, but never shown

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