angularjs html5mode refresh page get 404

前端 未结 6 754
轮回少年
轮回少年 2020-12-08 21:53

I\'ve created an app using AngularJS with GAE (Google App Engine – Java).

I want to convert it compatible with SEO.

index.html

6条回答
  •  暖寄归人
    2020-12-08 22:12

    It should be helpful, official angular doc; https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode

    Still I'll paste the relevent part here but I would advice to look at document.

    Apache Rewrites
    

    ServerName my-app

    DocumentRoot /path/to/app
    
    
        RewriteEngine on
    
        # Don't rewrite files or directories
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^ - [L]
    
        # Rewrite everything else to index.html to allow html5 state links
        RewriteRule ^ index.html [L]
    
    

    Nginx Rewrites

    server {
    server_name my-app;
    
    index index.html;
    
    root /path/to/app;
    
    location / {
        try_files $uri $uri/ /index.html;
    }
    }
    

    Azure IIS Rewrites

    
     
       
        
          
          
            
            
          
          
        
      
    
    

提交回复
热议问题