1

I want to deploy my Angular 5 app on a Tomcat 7 server, but there is a problem on redirection when i click on refresh button, i got always 404 error. On the angular site web, i found for Apache:

RewriteEngine On
    # If an existing asset or directory is requested go to it as it is
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteRule ^ - [L]
    # If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html

It works for Apache server but not for Tomcat, is there a similar config for Tomcat? Thank you

2
  • i use angular for the web site. Commented Mar 27, 2018 at 14:12
  • this may help Commented Apr 10, 2019 at 15:03

1 Answer 1

0

One solution to avoid the redirect it to fall back to using the hash mode:

RouterModule.forRoot(routes, {useHash: true})

Another option would be to write a dedicated Java servlet that would do the redirect.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.