我在CentOs上运行了一个apache服务器,我想在这个服务器上部署我的Angular4项目。该项目部署在/ var / www / html文件夹中。除了路由部分外,它工作正常。当我刷新或访问基本index.html中的不同URL时,我遇到404错误。
我点了这个链接:https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml但没有任何变化。
我的.htaccess:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html
我的/etc/httpd/conf/httpd.conf文件的一部分:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
404错误总是在这里。 我不知道如何解决这个问题。我做错什么了吗 ?提前致谢
答案 0 :(得分:3)
它正在使用root中的.htaccess:
https://mywebsite.com/#/
答案 1 :(得分:0)
我不确定您的重写配置是否正确(对Apache配置了解不多)。
我所知道的是你需要将404路由重定向到index.html。因此,如果有一种特殊的方法来重定向404路由,您可以尝试重写它。