# follow symlinks & disallow directory listing
# note: your hosting company might not allow these directives to be set. In that case,
# you should either find another hosting company (advised) or remove the line below.
Options +FollowSymlinks -Indexes
DirectorySlash Off

# Make sure the htaccess file is protected
<Files .htaccess>
    order allow,deny
    deny from all
</Files>

<IfModule mod_rewrite.c>
    # forbidden extensions
    RewriteRule \.asp - [F]
    RewriteRule \.cgi - [F]
    RewriteRule \.jsp - [F]
    RewriteRule \.md - [F]
    RewriteRule \.phar - [F]
    RewriteRule \.php - [F]
    RewriteRule \.php2 - [F]
    RewriteRule \.php3 - [F]
    RewriteRule \.php4 - [F]
    RewriteRule \.php5 - [F]
    RewriteRule \.php6 - [F]
    RewriteRule \.php7 - [F]
    RewriteRule \.php8 - [F]
    RewriteRule \.php9 - [F]
    RewriteRule \.pht - [F]
    RewriteRule \.phtml - [F]
    RewriteRule \.pl - [F]
    RewriteRule \.py - [F]
    RewriteRule \.sh - [F]
    RewriteRule \.shtml - [F]
    RewriteRule \.twig - [F]
    RewriteRule \.xhtml - [F]

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . index.php [L]
</IfModule>

# file caching in browser
<IfModule mod_expires.c>
    ExpiresActive On
    <FilesMatch "\.(?i:ico|gif|jpe?g|png|svg|svgz|js|css|swf|ttf|otf|woff|woff2|eot)$">
        ExpiresDefault "access plus 1 month"
    </FilesMatch>
</IfModule>

# gzip on Apache 2
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml text/javascript text/css application/x-javascript application/xhtml+xml application/javascript application/json image/svg+xml

    # these browsers do not support deflate
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch bMSIE !no-gzip !gzip-only-text/html

    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force
</IfModule>

# gzip on Apache 1
<IfModule mod_gzip.c>
    mod_gzip_on Yes

    mod_gzip_item_include mime ^application/javascript$
    mod_gzip_item_include mime ^application/x-javascript$
    mod_gzip_item_include mime ^application/json$
    mod_gzip_item_include mime ^application/xhtml+xml$
    mod_gzip_item_include mime ^application/xml$
    mod_gzip_item_include mime ^text/css$
    mod_gzip_item_include mime ^text/html$
    mod_gzip_item_include mime ^text/javascript$
    mod_gzip_item_include mime ^text/plain$
    mod_gzip_item_include mime ^text/xml$
    mod_gzip_item_exclude mime ^image/

    # browser issues
    mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]"
</IfModule>