Last active
March 24, 2025 22:33
-
-
Save 3m1n3nc3/9177774c8dbc1d7f26d5c1f6e47ad602 to your computer and use it in GitHub Desktop.
Perfect .htaccess file for SPA hosting on Apache servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <IfModule mod_rewrite.c> | |
| RewriteEngine On | |
| RewriteBase / | |
| RewriteRule ^index\.html$ - [L] | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule . /index.html [L] | |
| </IfModule> | |
| # No caching for all files | |
| <FilesMatch ".*"> | |
| Header set Cache-Control "no-cache, no-store, must-revalidate" | |
| </FilesMatch> | |
| # Caching for static assets | |
| <FilesMatch "\.(jpg|jpeg|gif|png|svg|webp|js|css|eot|otf|ttf|ttc|woff|woff2|font\.css)$"> | |
| Header set Cache-Control "max-age=604800, public" | |
| </FilesMatch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.