search

Home  >  Q&A  >  body text

angular.js - Angular2 is deployed to IIS, routing is invalid

I deployed the project to IIS, but the routing does not take effect when accessing. After entering the address directly, it does not jump to the response page, but displays 404

曾经蜡笔没有小新曾经蜡笔没有小新2841 days ago752

reply all(4)I'll reply

  • 某草草

    某草草2017-05-15 17:13:58

    Yes, the server does not have the resource corresponding to the address, and all requests must be redirected to the homepage

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-15 17:13:58

    url rewriteSet up?

    Nginx用的多,IIS I don’t know how to write it... The principle is similar

    location / {
        try_files $uri $uri/ /index.html =404; 
    }

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-15 17:13:58

    Did you use html5 pushstate but forgot to set the routing pointer on the server side?

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-15 17:13:58

    If it is a purely static file, IIS will look for the file in the corresponding directory based on the routing. If it cannot be found, it will naturally result in a 404.
    There are two ways to solve it:

    • Write a background route that renders the page. All routes return a page, such as index.html, and then the page can capture the route and handle it by itself

    • Set the url rewrite of IIS, you need to download this from Baidu

    reply
    0
  • Cancelreply