Last active
October 28, 2020 08:16
-
-
Save esedic/4cfb43cdb6b5827569f7 to your computer and use it in GitHub Desktop.
Using .htaccess to Move Your Site to SSL
This file contains 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
# Moving your whole site to SSL | |
# First rewrite to HTTPS: | |
# Don't put www. here. If it is already there it will be included, if not | |
# the subsequent rule will catch it. | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# Now, rewrite any request to the wrong domain to use www. | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# Excluding some pages from SSL | |
# Exceptions for HTTPS | |
RewriteCond %{HTTPS} off | |
RewriteCond %{QUERY_STRING} !^option=com_obrss&task=feed&id=1 | |
# UPDATE 2020: | |
RewriteEngine on | |
RewriteCond %{HTTPS} off | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} | |
# or | |
RewriteEngine on | |
RewriteBase / | |
RewriteCond %{HTTPS} !on | |
RewriteRule (.*) https://my.domain.name%{REQUEST_URI} [L,R=301] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment