<IfModule mod_rewrite.c>
RewriteEngine On
# store protocol in environment variable
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=protocol:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=protocol:http]
# make sure we point to the same content
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ %{ENV:protocol}://%1/$1 [R=301,L]
# don't rewrite site content
RewriteRule ^/site/ - [NC,L]
# make sure requested file name is not directory or file name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# take whole URI and give it to main index file
RewriteRule (.*) index.php?$1 [QSA,L]
</IfModule>
<FilesMatch ".(xml|json)$">
Deny from all
</FilesMatch>
<FilesMatch "^site/.*.(php|php3|asp|sh|py)$">
Deny from all
</FilesMatch>
<FilesMatch "^(install|docs|libraries|.git|.tx)/">
Deny from all
</FilesMatch>
<FilesMatch "favicon.ico">
Deny from all
</FilesMatch>
<FilesMatch "sitemap.xml$">
Allow from all
</FilesMatch>
# cache modifications
Header unset Pragma
<FilesMatch ".(ico|pdf|jpg|jpeg|png|gif)$">
Header set Cache-Control "max-age=864000, public, must-revalidate"
Header unset Last-Modified
</FilesMatch>
<FilesMatch ".(svg)$">
Header set Cache-Control "max-age=864000, public, must-revalidate"
SetOutputFilter DEFLATE
</FilesMatch>
<FilesMatch ".(js|css|less|ttf|otf|woff)$">
Header set Cache-Control "max-age=864000, must-revalidate"
SetOutputFilter DEFLATE
</FilesMatch>
<FilesMatch ".(html|php)$">
SetOutputFilter DEFLATE
</FilesMatch>