简体   繁体   English

角1.3.15 html5mode深层链接,路由,哈希

[英]angular 1.3.15 html5mode deeplinking, route, hash

I enabled html5mode true and placed <base href="/"> inside head tag. 我启用了html5mode true并将<base href="/">放置在head标签内。 It seems to be working fine. 它似乎工作正常。 But when I refresh a page, it gives me an error. 但是,当我刷新页面时,它给我一个错误。

The requested URL /updated_1/work was not found on this server. 

Found this in another post. 在另一个帖子中找到了这个。

This problem was due to the use of AngularJS 1.1.5 (which was unstable, and obviously had some bug or different implementation of the routing than it was in 1.0.7) 这个问题是由于使用了AngularJS 1.1.5(它是不稳定的,并且显然有一些bug或与1.0.7版本不同的路由实现)

turning it back to 1.0.7 solved the problem instantly. 将其恢复为1.0.7可立即解决该问题。

have tried the 1.2.0rc1 version, but have not finished testing as I had to rewrite some of the router functionality since they took it out of the core. 已经尝试了1.2.0rc1版本,但是还没有完成测试,因为我不得不重写某些路由器功能,因为他们将其从核心中删除了。

anyway, this problem is fixed when using AngularJS vs 1.0.7. 无论如何,当使用AngularJS vs 1.0.7时,此问题已解决。

Using old version gives more error. 使用旧版本会产生更多错误。 So I though to use latest version. 所以我虽然使用最新版本。 I'm using AngularJS v1.3.15. 我正在使用AngularJS v1.3.15。

Is that a problem with angular version? 角度版本有问题吗? Can some one suggest with best solution. 有人可以建议最好的解决方案。

Thanks 谢谢

You need to allow direct-linking of pages so they can be processed by Angular. 您需要允许页面的直接链接,以便Angular可以处理它们。 If you don't do this, when the user refreshes, they get a blank screen. 如果您不这样做,则当用户刷新时,他们会得到黑屏。

Create an .htaccess file inside your folder, and paste in this ( assuming your main file is named index.html ). 在文件夹内创建一个.htaccess文件,然后粘贴到其中(假设您的主文件名为index.html)。

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !index
    RewriteRule (.*) index.html [L]
</ifModule>

If the problem still persist, let me know. 如果问题仍然存在,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM