apache服务器上的角度部署

时间:2017-07-29 21:54:26

标签: apache angular .htaccess

我按照here概述的步骤进行了操作。 我将以下代码复制并粘贴到.htaccess文件中。 .htaccess文件位于包含我要在apache上部署的dist文件夹的同一个存储库中。

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

当我访问localhost/dist时一切正常,因为它将使用我的index.html文件,它会自动重定向到localhost/dist/login。现在,如果我直接请求localhost/dist/login,apache就会抱怨并显示The requested URL /dist/login was not found on this server.我觉得apache没有选择.htaccess设置。有什么我做错了吗?

1 个答案:

答案 0 :(得分:0)

最后我找到了解决问题的方法。也许这可以帮助一些人。我启用了Apache的rewrite mode而不是

RewriteRule ^ /index.html

我写了

RewriteRule ^ /dist/index.html

这解决了我的问题。