<IfModule mod_rewrite.c>
    RewriteEngine on

    #Force redirect to SSL
    #RewriteCond %{HTTPS} !=on
    #RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]


    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [L]

#    Redirect www urls to non-www.
#    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>

# Disable directory listing (highly recommended). Commented out as might not work on some hosts
Options -Indexes

# Disable accessing files without extension (recommended). Commented out as might not work on some hosts
Options -MultiViews

#Modified rules for 1and1 hosting
#AddHandler x-mapp-php5.4 .php3 .php4 .php .phtml
#RewriteEngine on
#RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ /index.php?%{QUERY_STRING} [L]


#Additional options to extend server limits. Commented out as might not work on some hosts
#php_value upload_max_filesize 1000M
#php_value post_max_size 1000M
#php_value memory_limit 100M

#Prevent certain extensions from being accessed
<FilesMatch "\.(dist|db|markdown|md|twig|yaml|yml|env)|(bower|composer|jsdoc|package)\.json$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order deny,allow
    Deny from all
  </IfModule>
</FilesMatch>

#Prevent your .htaccess file from being accessed directly. This uses Regex rules.
<Files ~ "^.*\.([Hh][Tt][Aa])">
  Order deny,allow
  Deny from all
  Satisfy all
</Files>

#Prevent your config.php configuration file from being accessed directly
<Files "config.php">
  Order deny,allow
  Deny from all
</Files>

######################### Gzip directives (Disable if they fail to work on your host's server)
<IfModule mod_deflate.c>
    AddType x-font/woff .woff
    AddType x-font/ttf .ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE x-font/ttf
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/opentype font/ttf font/eot font/otf
</IfModule>

######################### Cache control directives (Disable if they fail to work on your host's server)
<FilesMatch "\.(webm|ogg|mp4|ico|pdf|flv|avif|jpg|jpeg|png|gif|webp|js|css|swf|x-html|css|xml|js|woff|woff2|otf|ttf|svg|eot)(\.gz)?$">
    <IfModule mod_expires.c>
        AddType application/font-woff2 .woff2
        AddType application/x-font-opentype .otf
        ExpiresActive On
        ExpiresDefault A0
        ExpiresByType video/webm A10368000
        ExpiresByType video/ogg A10368000
        ExpiresByType video/mp4 A10368000
        ExpiresByType image/avif A10368000
        ExpiresByType image/webp A10368000
        ExpiresByType image/gif A10368000
        ExpiresByType image/png A10368000
        ExpiresByType image/jpg A10368000
        ExpiresByType image/jpeg A10368000
        ExpiresByType image/ico A10368000
        ExpiresByType image/svg+xml A10368000
        ExpiresByType text/css A10368000
        ExpiresByType text/javascript A10368000
        ExpiresByType application/javascript A10368000
        ExpiresByType application/x-javascript A10368000
        ExpiresByType application/font-woff2 A10368000
        ExpiresByType application/x-font-opentype A10368000
        ExpiresByType application/x-font-truetype A10368000
    </IfModule>
    <IfModule mod_headers.c>
        Header set Expires "max-age=A10368000, public"
        Header unset ETag
        Header set Connection keep-alive
        FileETag None
    </IfModule>
</FilesMatch>

######################### Cache control directives
# Comment out if you want to use

# <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
# Header set Cache-Control "max-age=31536000, public"
# </FilesMatch>

# <FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
# Header set Cache-Control "max-age=604800, public"
# </FilesMatch>

# <FilesMatch "\.(css|js)$">
# Header set Cache-Control "max-age=15552000, private"
# </FilesMatch>

# <FilesMatch "\.(html|htm|php)$">
# Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
# </FilesMatch>

########################## Vary-Encoding Headers

# <IfModule mod_headers.c>
#  <FilesMatch ".(js|css|xml|gz|html)$">
#    Header append Vary: Accept-Encoding
#  </FilesMatch>
# </IfModule>