简体   繁体   中英

angular 1.3.15 html5mode deeplinking, route, hash

I enabled html5mode true and placed <base href="/"> inside head tag. 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)

turning it back to 1.0.7 solved the problem instantly.

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.

anyway, this problem is fixed when using 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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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