Created
July 17, 2017 18:22
-
-
Save stephensabatini/daf8a710c69fa7dec40996c5d83f285c to your computer and use it in GitHub Desktop.
Snippet of Security Tweaks for the .htaccess.
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
# Deny access to include files. | |
<Files ~ "\.inc$"> | |
Order Allow,Deny | |
Deny from All | |
</Files> | |
# Deny access to hidden files. | |
RedirectMatch 403 /\..*$ | |
# Deny access to folders. | |
Options +ExecCGI +FollowSymLinks -MultiViews -Indexes | |
<IfModule mod_headers.c> | |
# Prevent MIME based attacks. | |
Header set X-Content-Type-Options "nosniff" | |
# Disallow iframes of your website on other sites. | |
Header set X-Frame-Options "sameorigin" | |
# Cross-Site-Scripting Protection | |
Header set X-XSS-Protection "1; mode=block" | |
</IfModule> | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
# Prevent image hotlinking. | |
RewriteCond %{HTTP_REFERER} . | |
RewriteCond %{HTTP_REFERER} !^(.*)://example.com(.*) [NC] | |
RewriteCond %{HTTP_REFERER} !^(.*)://(.*).example.com(.*) [NC] | |
RewriteCond %{HTTP_REFERER} %{REMOTE_ADDR} | |
RewriteRule \.(jpe?g|png|svg|gif|bmp|js|css)$ - [F,L] | |
# Enforce HTTPS/SSL. | |
RewriteCond %{HTTPS} off | |
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment