我如何将404错误页面重定向到000webhost.com服务器中的主页,因为我像Angular 6一样使用SPA。因此,当我输入错误的URL时,它会将我重定向到主页;
这是我的主页网址
输入了错误的网址
它应该将我重定向到主页
,谢谢!
答案 0 :(得分:-1)
当我在主机服务器中更改.htaccess文件时,它对我很有用
# HTID:6816226: DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES BELOW
Redirect 301 /employees/login https://agina.000webhostapp.com/employees/
# DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES ABOVE HTID:6816226:
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 ^ /employees/index.html