Tuesday, May 26, 2009

Redirect all traffic from port 80 to port 443 https in Apache2

Force an SSL connection and redirect all traffic from port 80 (HTTP) to port 443 (HTTPS), use this instead:
(assuming: Apache2 Listen on 80 and 8080)


RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]

RewriteCond %{SERVER_PORT} ^8080$
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]

RewriteLog "logs/rewrite.log"
RewriteLogLevel 2

No comments:

Post a Comment