We Recommend

Pro Apache Pro Apache
In addition to installation, maintenance, and deployment, the book demonstrates how to configure Apache to use Perl, PHP, and Python as server-side scripting languages. And unlike other books on Apache, Pro Apache provides comprehensive information on both major revisions - 1.3 and 2.0 - of the software.


Posted By

Scooter on 05/19/08


Tagged

htaccess ssl


Versions (?)


Force SSL


Published in: Apache 


URL: http://reusablecode.blogspot.com/2008/04/force-ssl.html

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.