我已经在aws服务器上部署了一个angular 5应用程序。网页仅在默认URL上加载。没有路由URL工作,它抛出"在此服务器上找不到请求的URL/routecomponent"错误。
{ path: '', component: routecomponent } // load this page
{ path: 'home', component: routecomponent } // doesn't load
HTACCESS文件
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://angular.io/guide/deployment
它演示了如何将--base-href
设置为用于路由的适当文件夹。