Last active
September 27, 2019 22:22
-
-
Save zephyrmike/0394d146234534fa343cc64361ce31d9 to your computer and use it in GitHub Desktop.
Useful HTACCESS Rules
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
/* http to https with www to non-www */ | |
RewriteEngine On | |
RewriteCond %{HTTPS} off [OR] | |
RewriteCond %{HTTP_HOST} ^www\. [NC] | |
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] | |
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301] | |
/* http to https with non-www to www */ | |
RewriteEngine On | |
RewriteCond %{HTTPS} off [OR] | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] | |
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301] | |
/* prevent hotlinking */ | |
RewriteEngine on | |
RewriteCond %{HTTP_REFERER} !^$ | |
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC] | |
RewriteRule \.(gif|jpg|png|svg)$ - [F] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment