Created
February 16, 2010 23:58
-
-
Save briandoll/306100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# within your vhost... | |
RewriteEngine On | |
# create a variable called 'ps' which stores the original scheme | |
RewriteCond %{HTTPS} =on | |
RewriteRule ^(.+)$ - [env=ps:https] | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^(.+)$ - [env=ps:http] | |
# if the hostname (in this case, including the subdomain) does not match our desired hostname | |
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] | |
# redirect it to the correct hostname, using the original scheme and the rest of the URL | |
RewriteRule ^(.*)$ %{ENV:ps}://www.example.com$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment