Posted By

Scooter on 05/19/08


htaccess ssl

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Force SSL

 / Published in: Apache


There are some things here worth noting. We are checking if HTTPS is off. Some people will instead check if traffic is coming from port 80, the standard HTTP port, or not coming from 443, the standard HTTPS port. Checking port numbers is not the best solution because the server administrator can set up HTTP and HTTPS to run on different ports. It's also worth noting that QueryString variables are preserved, if any are being passed. Most other examples I've seen on the Internet ignore the QueryString variables, which leads to navigation problems.

  1. RewriteEngine On
  2. RewriteCond %{HTTPS} off
  3. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Report this snippet  

You need to login to post a comment.