【发布时间】:2018-10-16 13:49:55
【问题描述】:
我试过了 this answer 并且可以确认我的主机上启用了 mod_rewrite
我已经从各种答案和网站尝试了以下 .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
根据一些要点
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
还有许多其他人,但都给出了 404 错误。任何方式来调试它。
我正在使用ng build --prod 创建一个dist,然后在dev.example.com 上托管并尝试访问dev.example.com/home,从dev.example.com 访问时可用
可能是由于子域吗?
【问题讨论】:
-
你能访问 dev.example.com/index.html 吗?
-
是的,由于我的路由,它重定向到
dev.example.com/home -
@BlackMamba:你同时使用这两个配置吗?首先在您的
vHost和其他htaccess?或者您在htaccess中一次尝试了一个?第二个对我来说似乎不正确,虽然第一个对我来说看起来不错,但我会发布我使用的内容.. -
一次尝试每一个。在我的回答中添加了一些观察结果,请检查。
标签: angular apache .htaccess deployment production