rewrite rules for apache 2 to use with angular js

前端 未结 5 1933
长情又很酷
长情又很酷 2020-12-02 23:23

Obviously, there are a lot of mod rewrite discussions and answers all across the web. However, I am having a hard time grasping them. So I thought I would ask here.

5条回答
  •  长情又很酷
    2020-12-02 23:59

    From my production server:

    
            ServerName XXX.com
    
            DocumentRoot /home/www/XXX.com/www
    
            # Local Tomcat server
            
              ProxyPass http://localhost:8080/api/
              ProxyPassReverse http://localhost:8080/api/
            
    
            RewriteEngine On
    
            # If an existing asset or directory or API is requested go to it as it is
            RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
            RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
            RewriteCond %{REQUEST_URI} /api
            RewriteRule ^ - [L]
    
            # If the requested resource doesn't exist (and is not API), use index.html
            RewriteRule ^ /index.html
    
            ErrorLog logs/XXX.com-error.log
            CustomLog logs/XXX.com-access.log common
    
    

    Please note, that "!" before "/api" in the accepted answer is incorrect.

提交回复
热议问题