【发布时间】:2018-02-01 21:58:49
【问题描述】:
我有一个在 CentO 上运行的 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 错误总是在这里。 我不知道如何解决这个问题。我做错什么了吗 ?提前致谢
【问题讨论】:
标签: angular apache .htaccess url-routing