0

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?

Jeeten Parmar
  • 5,568
  • 15
  • 62
  • 111

2 Answers2

0

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.

LoïcR
  • 4,940
  • 1
  • 34
  • 50
  • As per your opinion, what is the best solution ? `HashLocationStrategy` or redirection rules ? – Jeeten Parmar Dec 07 '16 at 09:17
  • HashLocationStrategy obviously cause amazon s3 is not permenant solution and if you shift to shared hosting or subdomain then you will need HashLocationStrategy again – anshuVersatile Dec 07 '16 at 09:22
0

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

Community
  • 1
  • 1
anshuVersatile
  • 2,030
  • 1
  • 11
  • 18