# Default force to HTTPS for all traffic
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Force SSL / HTTPS Redirection v2
Options +FollowSymLinks
Options -Indexes
Options -MultiViews
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Force non-www:
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
# Deny and than redirect every IP that is not on the whitelist
# Protect a specific directy by creating another .htaccess file ^ _ ^
order deny,allow
allow from 192.168.1.420
deny from all
ErrorDocument 403 https://redirect-visitor.com
# Prevent viewing of .htaccess file.
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Optimize website, enable compression gzip
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>