# Coliving Express — pretty URLs for Apache
# All requests fall through index.php (except real files in /public/uploads,
# the installer and assets). The router handles the rest.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Allow installer and its assets through untouched.
    RewriteRule ^install\.php$ - [L]
    RewriteRule ^public/ - [L]

    # If the request points at a real file or directory, serve it.
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Send everything else through the front controller.
    RewriteRule ^(.*)$ index.php [L,QSA,E=ROUTE:$1]
</IfModule>

# Prevent directory listings.
Options -Indexes

# Block access to dotfiles and the config directory.
<FilesMatch "^\.">
    Require all denied
</FilesMatch>

<IfModule mod_alias.c>
    RedirectMatch 403 ^/config/.*$
    RedirectMatch 403 ^/database/.*$
    RedirectMatch 403 ^/app/.*$
</IfModule>
