Angular2 routing / deep linking not working with Apache 404

前端 未结 7 2005
自闭症患者
自闭症患者 2020-11-29 01:17

I am following the Angular 2 routing examples. Using the \"lite\" webserver I am able to navigate from the root and deep linking works, but using Apache I can navigate fro

相关标签:
7条回答
  • 2020-11-29 02:23

    For those who's running on Apache use this .htaccess

    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} -s [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
    
        RewriteRule ^(.*) /index.html [NC,L]
    </IfModule>
    

    If you still get an error run those 2 commands:

    sudo a2enmod rewrite
    sudo systemctl restart apache2
    
    0 讨论(0)
提交回复
热议问题