search

Home  >  Q&A  >  body text

restful - How does nginx tell that the request is a dynamic request without a .php match?

Now many RESTful frameworks, or frameworks that support pathinfo routing mode, will hide the entry file index.* in the URL. So, in this case, how to configure nginx so that it can determine whether the request is a dynamic request that requires program processing, or a static file request?

黄舟黄舟2754 days ago860

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 17:28:50

    location /  
    {  
        index index.php;  
        # 重写到index  
        if ($request_filename !~ (js|css|images|robots/.txt|index/.php.*) ) {  
            rewrite ^/(.*)$ /index.php/ last;  
            break;  
        }  
    } 
    

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 17:28:50

    server {
        root            /site/root;
    
        location @cgi {
            include         fastcgi_params;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_param   SCRIPT_FILENAME /site/root/index.php;
        }
    
        location / {
            try_files $uri @cgi;
        }
    }
    

    reply
    0
  • Cancelreply