如何从URL网站上基于angularjs删除的index.html [英] How to remove index.html from url on website based on angularjs

查看:102
本文介绍了如何从URL网站上基于angularjs删除的index.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有找到一个方法来从URL中移除的index.html,因为这样看起来很丑陋。

I didn't find a way to remove index.html from the url, because like this looks really ugly.

mydomain.com/index.html#/myview1 
mydomain.com/index.html#/myview2

有没有办法去除这部分,像URL会那么清楚用户所在。

Is there a way to remove that part, like that url will be so clear where the user is.

mydomain.com/myview1
mydomain.com/myview2

TNX提前为你的时间。

Tnx in advance for your time.

编辑:
我只是觉得方式,它可以工作,如:

I just find way that it could work like:

mydomain.com/#/myview1
mydomain.com/#/myview2

这是pretty好得多然后用index.html的。

which is pretty much better then with index.html.

但还是如果有一个较短的解决方案的方式让我知道。

But still if there is a way for shorter solution let me know.

推荐答案

您必须做在服务器端的一些工作来设置起来。 html5mode让你的方式的一部分,但只要用户刷新时,参考的文件会出错。你想要的是持久的,可以共享,presumably链接。基本上确保url.com/myapp/{etc~~V任何请求}(或其他)被重定向到index.html,然后让你的应用程序的角度理清路由。

You'll have to do some work on the server side to set this up. html5mode gets you part of the way, but as soon as the user refreshes, the reference to the file will be wrong. You want links that are persistent and can be shared, presumably. Basically make sure any request to url.com/myapp/{etc} (or whatever) gets redirected to index.html and let your angular app sort out the routing.

这篇关于如何从URL网站上基于angularjs删除的index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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