Deploy Angular 4 App on Apache Webserver

自闭症网瘾萝莉.ら 提交于 2021-02-04 16:34:46

问题


I want to deploy my Angular Application on my Apache Webserver. I already added a .htaccess file to my /var/www/html folder, I tried several base-hrefs. But like many people I have problems with routing. I can only see my Startpage, but when I want to get to a other URL it fails. What else can I try or have I missed something?


回答1:


You have to enable/install the Apache mod_rewrite module, and then put this in either your .htaccess or your apache configuration for your site:

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



回答2:


Uncomment this line at "/etc/apache2/httpd.conf"

#LoadModule rewrite_module libexec/apache2/mod_rewrite.so

To

LoadModule rewrite_module libexec/apache2/mod_rewrite.so



来源:https://stackoverflow.com/questions/47302373/deploy-angular-4-app-on-apache-webserver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!