问题
I am currently learning Angular. I have implemented routers using HashLocation, because PathLocation is not working in Apache server. I went through various posts to solve that, but in the end have to settle with HashLocation for Apache.
I just want to know that if there is any downside of HashLocation, like is there any Angular feature that does not work with HashLocation and can I use HashLocation for production ready apps?
回答1:
According to, https://angular.io/docs/ts/latest/guide/router.html#!#which-strategy-is-best-
Almost all Angular projects should use the default HTML5 style. It produces URLs that are easier for users to understand. And it preserves the option to do server-side rendering later.
Server side rendering makes your app faster and more secure.
回答2:
Advantages of clean URL/ path location strategy include A. SEO friendliness B. Caching of resources or i.e static assets.
If this 2 can be ignored for your usecase, you can go with hash location strategy.
To configure path location in apache You need to add this in your .htaccess file.
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
来源:https://stackoverflow.com/questions/43833103/is-there-any-downside-of-hashlocation-strategy