Page reload fails when using Angular Ui Router with Html5 mode enabled

后端 未结 7 1321
醉酒成梦
醉酒成梦 2020-12-03 03:41

I am using Angular UI Router in my angular app and i have enabled HTML5 mode to remove the # form the URL by using $locationProvider in the config.



        
相关标签:
7条回答
  • 2020-12-03 04:20

    You need to to setup url rewrite on server side

    for apache it would be something like:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.html
    

    in .htaccess file(be sure that mod_rewrite apache module is enabled)

    and config like this for nginx:

    location / {
        ....
        try_files $uri $uri/ /index.html =404;
    }
    
    0 讨论(0)
提交回复
热议问题