# --------------------------------------------------------------- OpenStore
# Apache rewrite for the public/ document root.
# Nothing here needs AllowOverride All beyond this file; if your vhost uses
# "AllowOverride None", copy the RewriteBlock into the server config.

Options -Indexes -MultiViews
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Requests already pointing at the installer must not be re-written.
    RewriteCond %{REQUEST_URI} ^/install [NC]
    RewriteRule ^ - [L]

    # Real files and real folders are served as they are.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L,QSA]
</IfModule>

# Dotfiles and backups are never web readable.
<FilesMatch "^\.|\.(env|ini|log|sh|sql|bak|old|zip)$">
    Require all denied
</FilesMatch>

# Block direct access to anything that looks like a PHP template or config.
<FilesMatch "\.(tpl|twig|md|yml|yaml)$">
    Require all denied
</FilesMatch>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json image/svg+xml
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 30 days"
    ExpiresByType image/png "access plus 30 days"
    ExpiresByType image/webp "access plus 30 days"
    ExpiresByType image/svg+xml "access plus 30 days"
    ExpiresByType text/css "access plus 7 days"
    ExpiresByType application/javascript "access plus 7 days"
</IfModule>
