<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /public/

    # Redirect to index.php if the requested resource doesn't exist
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule>

# Prevent access to sensitive files
<FilesMatch "\.(env|git|gitignore|composer|phpunit\.xml|\.php|\.scss|\.md|\.log|\.yml|\.yml|\.htaccess|\.git|\.svn|\.idea|\.DS_Store)$">
    Order Deny,Allow
    Deny from all
</FilesMatch>

# Allow .htaccess to be used for security and configuration
<Files .htaccess>
    Order Allow,Deny
    Allow from all
</Files>

# Set up headers for caching of assets
<IfModule mod_headers.c>
    <FilesMatch "\.(jpg|jpeg|png|gif|js|css|woff|woff2|ttf|svg)$">
        Header set Cache-Control "max-age=31536000, public"
    </FilesMatch>
</IfModule>
