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?
Asked
Active
Viewed 873 times
0
Jeeten Parmar
- 5,568
- 15
- 62
- 111
-
you can do with apache configuration but on amazon s3 I suspect you can access apache conf else the better way is to implement HashLocationStrategy – anshuVersatile Dec 07 '16 at 07:41
-
@anshuVersatile, I don't want `#` that's why I am looking for alternate solution. – Jeeten Parmar Dec 07 '16 at 07:44
2 Answers
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
-
As per your opinion, what is the best solution ? `HashLocationStrategy` or redirection rules ? – Jeeten Parmar Dec 07 '16 at 09:17