Last active
September 10, 2017 04:48
-
-
Save weblogix/145e7650d8f567e9f2c653516a5b2459 to your computer and use it in GitHub Desktop.
[Apache htaccess examples] htaccess rules #htaccess #apache
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
# Source: https://really-simple-ssl.com/knowledge-base/manually-insert-htaccess-redirect-http-to-https/ | |
If you see #SERVER-HTTPS-ON# (on), add | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{HTTPS} !=on [NC] | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
If you see #SERVER-HTTPS-ON# (1), add | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{HTTPS} !=1 | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
If you see #SERVERPORT443#, add | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{SERVER_PORT} !443 | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
If you see #LOADBALANCER#, add | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
If you see #CDN#, add | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{HTTP:X-Forwarded-SSL} !on | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
If you see #Cloudflare#, add | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{HTTP:CF-Visitor} ‘”scheme”:”http”‘ | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
If you see #ENVHTTPS#, add | |
<IfModule mod_rewrite.c> | |
RewriteEngine on RewriteCond %{ENV:HTTPS} !=on | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment