如何在Firebase托管中实施.htaccess配置? [英] How can I implement a .htaccess configuration in Firebase Hosting?

查看:42
本文介绍了如何在Firebase托管中实施.htaccess配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的域中有一个.htaccess配置,该配置允许我的应用与路由完美配合.当您刷新angular 2应用无法解析路由时,它可以避免错误.

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.

我当前的配置是这个

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

我正在尝试在Firebase Hosting中实现相同的配置,因为我正在迁移网站,我不知道如何将.htaccess转换为Firebase Hosting配置.

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.

有什么简单的方法吗?

推荐答案

您不能在

You can't use .htaccess in Firebase hosting, but you can configure it to rewrite, redirect, cache, etc.

在此处了解如何自定义托管行为.

您的.htaccess将被翻译为

"hosting": {
  "rewrites": [ {
    "source": "**/!(*.css|*.js|*.map|*.jpg|*.gif|*.png|*.php)",
    "destination": "/index.html"
  } ]
}

这篇关于如何在Firebase托管中实施.htaccess配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆