Last active
July 6, 2019 02:09
-
-
Save zspine/23aaad169de5a2bfe2df to your computer and use it in GitHub Desktop.
htaccess cheatsheet
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
#Hide directories and files | |
Options -Indexes | |
#Set Enviroment Varaibles | |
SetEnv APPLICATION_ENV "development" | |
# Enable the rewrite engine | |
RewriteEngine On | |
# redirect non www to www | |
RewriteCond %{HTTP_HOST} !^$ | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteCond %{HTTPS}s ^on(s)| | |
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
# Force SSL | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# Forece SSL and the www | |
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] | |
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this will surely help. i would like to add on to this, here you can find various htaccess exploits , types of htaccess hack attacks alongwith snippets and how to clean up the hack. I am sure this will be a handy resource to go alongwith - https://secure.wphackedhelp.com/blog/wordpress-htaccess-hacked-exploit-cleanup/