How can i implement a .htaccess configuration in Firebase Hosting

耗尽温柔 提交于 2019-12-07 09:03:24

问题


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 ths 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?


回答1:


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"
  } ]
}


来源:https://stackoverflow.com/questions/46130632/how-can-i-implement-a-htaccess-configuration-in-firebase-hosting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!