I have in my domain a .htaccess configuration that allows my app to work perfectly with the routes. It avoids the error when you refresh an angular 2 app can't resolve the routes.
My current config is this one
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# not rewrite css, js and images
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png|php)$ [NC]
RewriteRule ^(.*)$ /index.html?path=$1 [NC,L,QSA]
</IfModule>
I'm trying to implement the same configuration in my Firebase Hosting because I'm migrating my site, I don't know how to translate from .htaccess to Firebase Hosting configuration.
Is there any simple way to do it?
You can't use .htaccess
in Firebase hosting, but you can configure it to rewrite, redirect, cache, etc.
Learn how to customize hosting behavior here.
Your .htaccess
would be translated to
"hosting": {
"rewrites": [ {
"source": "**/!(*.css|*.js|*.map|*.jpg|*.gif|*.png|*.php)",
"destination": "/index.html"
} ]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With