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 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?

share|improve this question
add comment

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.

share|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
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.