# ImageHost: clean URLs and protection for private folders.
Options -Indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Never serve code, data or config files directly.
    RewriteRule ^(app|storage)(/|$) - [F,L]
    RewriteRule ^config\.php$ - [F,L]
    RewriteRule (^|/)\. - [F,L]

    # Work out the folder the app lives in, so it runs from / or any
    # sub folder (also behind Alias) without setting RewriteBase.
    RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
    RewriteRule .* - [E=IH_BASE:%1]

    RewriteRule ^$ %{ENV:IH_BASE}/index.php [L,E=IH_REWRITE:1]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ %{ENV:IH_BASE}/index.php [L,QSA,E=IH_REWRITE:1]
</IfModule>

<FilesMatch "\.(sqlite|sqlite-wal|sqlite-shm|log|md)$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>

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