AngularJS HTML5Mode [英] AngularJS HTML5Mode

查看:125
本文介绍了AngularJS HTML5Mode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的角度应用程序中使用HTML5模式,关闭hashbangs,这是因为我要为我的用户需要提供的网址,如:

I am using HTML5 mode in my angular app to turn off hashbangs and that is because I am going to be providing URLs for my users like:

http://myapp.com/nicklewis

而不是:

HTTP://myapp.com#/nicklewis

后者的作品,但它不是理想的个性化网址。

The latter works but it isn't ideal for vanity URLs.

这么短写我自己的应用程序的NodeJS解决这个问题,有没有什么火力地堡,我可以使用或不?

So short of writing my own NodeJS app to resolve this issue, is there anything in Firebase I could make use of or not?

推荐答案

火力地堡刚刚有了一个新的更新,其中包括此功能。您可以在firebase.json使用它像这样:

Firebase just had a recent update that included this functionality. You can use it like so in your firebase.json:

"rewrites": [ {
    "source": "**",
    "destination": "/index.html"
} ]

这是在他们的文档中使用的code样本,将发送未发现回index.html的任何目录或文件。

This is the code sample used in their docs and will send any directory or file that is not found back to index.html.

要注意的是,你需要更新你的火力部署工具来 1.1.0版或更高这一点很重要这个工作:

It's important to note that you will need to update your firebase deployment tools to version 1.1.0 or higher for this to work:

$ npm update -g firebase-tools

您可能需要使用'须藤'这个取决于您的权限。

You may need to use 'sudo' with this depending on your permissions.

您可以在这里阅读文档:<一href=\"https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html\">https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html

You can read the documentation here: https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html

您可以了解这里更新火力工具:<一href=\"https://www.firebase.com/docs/hosting/guide/command-line-tool.html\">https://www.firebase.com/docs/hosting/guide/command-line-tool.html

You can read about updating firebase tools here: https://www.firebase.com/docs/hosting/guide/command-line-tool.html

这篇关于AngularJS HTML5Mode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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