html - Angular:返回 URL 错误:在此服务器上找不到请求的 URL
问题描述
我有一个问题,我有一个网站,其中返回上一页会生成此错误:
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the
request.
当我在我的网站中单击指向另一个外部 URL 的链接时,就会发生这种情况;然后当我点击返回我的页面时
这就是我以角度设置路线的方式:
export const appRoutes: Routes = [
{path: 'users', component: UsersListComponent},
{path: 'products', component: ProductListComponent},
{path: '**', redirectTo: 'users', pathMatch: 'full'}
];
当我构建我的应用程序时,我认为这是我的基本路径index.html
<title>ProductsWebApp</title>
<base href="/">
我还想指定该页面确实存在 可能是什么问题?
解决方案
我终于通过将以下内容添加到我的.htaccess
文件来解决我的问题
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) index.html [NC,L]
</IfModule>
可以在此链接中找到更多信息
推荐阅读
- angularjs - 如何在 datetimepicker 中为 minView 设置动态值?
- r - 单击多边形并将 updateselectinput() - (使用传单 R)
- python - 将 csr_matrix 中的几列归零
- c# - 截止日期的警报消息作为提醒
- amazon-web-services - Kibana 部署到 Kubernetes 集群返回 404
- vbscript - 如何检查 HTA VBScript 中的文件大小?
- windows-services - 避免在 Tomcat 的 service.bat 中使用 jvmOptions 并使用在 catalina.bat 中设置的 JAVA_OPTS
- web-crawler - 爬虫不只爬几页,还爬其他所有内容
- ruby-on-rails - 如何在 rails 中的一种方法上有两个不同的 redirect_to 操作?
- php - 使用 PHP 将 3 张 jpg 图像相互叠加