45 lines
1.3 KiB
ApacheConf
45 lines
1.3 KiB
ApacheConf
# Disable directory listing
|
|
Options -Indexes
|
|
|
|
# Default directory index
|
|
DirectoryIndex index.html
|
|
|
|
# Serve index.html for SPA client-side routing (if file/dir doesn't exist)
|
|
<IfModule mod_rewrite.c>
|
|
RewriteEngine On
|
|
RewriteBase /
|
|
# If the request is for an existing file or directory, serve it
|
|
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
|
RewriteRule ^ - [L]
|
|
# Otherwise rewrite to index.html
|
|
RewriteRule ^ index.html [L]
|
|
</IfModule>
|
|
|
|
# Optional: small caching hints for static assets
|
|
<IfModule mod_expires.c>
|
|
ExpiresActive On
|
|
ExpiresByType text/css "access plus 1 week"
|
|
# Keep JS cache short during development to avoid stale scripts on mobile
|
|
ExpiresByType application/javascript "access plus 60 seconds"
|
|
ExpiresByType image/* "access plus 1 week"
|
|
</IfModule>
|
|
|
|
<IfModule mod_headers.c>
|
|
# Add Cache-Control headers for more precise control
|
|
<FilesMatch "\.js$">
|
|
Header set Cache-Control "max-age=60, public"
|
|
</FilesMatch>
|
|
<FilesMatch "\.css$">
|
|
Header set Cache-Control "max-age=604800, public"
|
|
</FilesMatch>
|
|
<FilesMatch "\.(png|jpg|jpeg|gif|svg)$">
|
|
Header set Cache-Control "max-age=604800, public"
|
|
</FilesMatch>
|
|
</IfModule>
|
|
|
|
# Prevent serving hidden files (like .env, .git)
|
|
<FilesMatch "^\..+">
|
|
Require all denied
|
|
</FilesMatch>
|