-
-
Save andresmgsl/c3f558ca8916f7a6e7e59bbad196c1c9 to your computer and use it in GitHub Desktop.
Optimal .htaccess configuration for an Angular 5 App in production
This file contains 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
# place this file in the same folder as your index.html on your server | |
# make sure to set the right base href attribute in your index.html | |
# this file ist hosted on GithubGist: | |
# https://gist.github.com/julianpoemp/bcf277cb56d2420cc53ec630a04a3566 | |
# REDIRECTION | |
# to index.html to make routing work in production | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} -s [OR] | |
RewriteCond %{REQUEST_FILENAME} -l [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^.*$ - [NC,L] | |
RewriteRule ^(.*) index.html [NC,L] | |
</IfModule> | |
# BROWSER CACHING | |
# disable browser caching in production. | |
#<FilesMatch "\.(html|htm|js|json|css)$"> | |
# <IfModule mod_headers.c> | |
# FileETag None | |
# Header unset ETag | |
# Header unset Pragma | |
# Header unset Cache-Control | |
# Header unset Last-Modified | |
# Header set Pragma "no-cache" | |
# Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" | |
# Header set Expires "Mon, 10 Apr 1972 00:00:00 GMT" | |
# </IfModule> | |
#</FilesMatch> | |
# | |
# It is recommended to add these tags to your index.html, too: | |
# <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"> | |
# <meta http-equiv="Pragma" content="no-cache"> | |
# <meta http-equiv="Expires" content="0"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment