gpt4 book ai didi

Apache 与 Angular2 - 404 未找到

转载 作者:行者123 更新时间:2023-12-03 02:56:04 25 4
gpt4 key购买 nike

我已经使用 Bitnami 镜像在 AWS 服务器上部署了 Angular2 应用程序。该应用程序由 Apache 提供服务(在端口 8080 上配置了虚拟主机),只要我从 index.html 启动,它就可以正常工作。如果我想访问不同的页面(已在 RouteConfig 中配置),我会收到 404 not found 错误。这是虚拟服务器的配置:

Listen 8080
<VirtualHost _default_:8080>
DocumentRoot "/opt/bitnami/apps/MyApp"
<Directory "/opt/bitnami/apps/MyApp">
Options All
Require all granted
</Directory>
</VirtualHost>

最佳答案

.htaccess 文件添加到根文件夹。我正在使用这个:

# BEGIN ServeStatic

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>

# END ServeStatic

它为所有可能导致 404 的请求提供 index.html...

关于Apache 与 Angular2 - 404 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35689696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com