PDA

View Full Version : Forcing SSL only connection


Norman
12th July 2007, 05:06
Say a site has SSL enabled. It's still possible to connect to non-SSL.

What's the best way to force incoming connections to apache on port 80 to go to the SSL port? Redirect somehow?

Ben
12th July 2007, 09:05
Try it with the following mod_rewrite rule


RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Norman
12th July 2007, 16:41
Seems to work. Will this prevent anyone trying to surf unencrypted though?

Ben
13th July 2007, 10:06
I woul say yes, cause in my tests in redirected / rewrote every access without http to https