Deploy angular application on Apache Tomcat 404 deep links issue

后端 未结 2 1710
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-05 15:31

I\'m trying to figure out the way how to setup Apache Tomcat server to serve angular application with deep links. For example:

A static server routinely returns ind

2条回答
  •  没有蜡笔的小新
    2020-12-05 15:58

    For fixing the deep link issue when deploying angular application (with PathLocationStrategy routing) on apache tomcat server (8, 9) -

    1. Configure the RewriteValve in server.xml
    2. Write the rewrite rule in rewrite.config

    server.xml -

    ...
          
    
            
    
    ...
          
    ...
    

    rewrite.config - (note - /hello/ is the context path of the angular app on tomcat)

    RewriteCond %{REQUEST_PATH} !-f
    RewriteRule ^/hello/(.*) /hello/index.html
    

    I have documented this issue in my article - Fixing deep linking issue – Deploying angular application on Tomcat server

    Note - there is no client side setup needed for achieving this (apart from the default config coming out of CLI). All the client side routing is handles by the Angular Routing module.

提交回复
热议问题