If I go on any page by click on any routerLink then it is working fine but If I refresh page then it shows 404 error. I came to know about HashLocationStrategy and so I need to use #. But I am looking for alternate solution.

Is there any way by which I can access page even when I refresh and that is without HashLocationStrategy ?

I am using Angular 2 and my website is hosted on aws s3. What is the best solution - HashLocationStrategy or redirection rules ?

2 Answers

Sakuto On

According to the official documentation you can write your custom redirection rules.

Just write your to redirect everything to the index.html page except /api or whatever is your API endpoint.

anshuVersatile On

Angular2 routing / deep linking not working with Apache 404

the above link will help you for configure server to redirecting to specific location and as @Sakuto suggested use amazon redirection rules