Angular route with html5Mode giving 'Not found' page after reload

后端 未结 2 1341
不思量自难忘°
不思量自难忘° 2020-12-30 16:50

I made some Angular routes as shown in the code bellow.

app.config(function($routeProvider, $locationProvider, $provide) {
    $routeProvider
    .when(\'/\'         


        
相关标签:
2条回答
  • 2020-12-30 17:08
    #BEGIN
    

    Options +FollowSymLinks

    <ifModule mod_rewrite.c>
        RewriteEngine on
    
        # Don't rewrite files or directories
         RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} -s [OR]
       RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
    
       RewriteRule ^(.*) your root folder/index.php [NC,L]
    
     </ifModule>
       #END
    

    its working 100% <base href="/"></base> also add to your index.html code in <head>section

    0 讨论(0)
  • 2020-12-30 17:09

    I solved it myself.. you always need to make a .htaccess file in the root of your project. Containing the following:

     <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
     </IfModule>
    
    0 讨论(0)
提交回复
热议问题