0

Can someone solve Nginx routing issue my conf file has the following location section

  location /pages {
     alias /path/to/dist/folder
     index index.html;
   }

when I am hitting http://example.com/pages, I am getting http:example.com/pages/home page as per angular 4 routing, but when I directly hit http:example.com/pages/home -its throwing bad request 502

1 Answer 1

2

Try the following redirection of routes to the index.html

index index.html;

location / {
  try_files $uri $uri/ /index.html;
}
Sign up to request clarification or add additional context in comments.

3 Comments

It will redirect each and every request to the index.html page, then how can I know for which page the user has requested originally?
The path stays the same, it's just what is served that will always be the index.html. That way any routing you defined in your app will pick up and handle what the user wanted to navigate to.
Can you please have a look at this question stackoverflow.com/questions/49332924/angular-5-routing-issue

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.