The vast majority of web servers such as Apache, IIS, and nginx do not allow static files to respond to POST requests. Otherwise, the error "HTTP/1.1405Methodnotallowed" will be returned. Example 1: Use the curl Command in linux to send a POST request to the HTML static page on the Apache server [root @ localhost ~] # Curl-d11 = 1 http://www.92csz.com/ind
The vast majority of web servers such as Apache, IIS, and nginx do not allow static files to respond to POST requests. Otherwise, an "HTTP/1.1 405 Method not allowed" error will be returned.
Example 1: Use the curl Command in linux to send a POST request to the HTML static page on the Apache server
[root@localhost ~]# curl -d 11=1 http://www.92csz.com/index.html 405 Method Not Allowed Method Not Allowed The requested method POST is not allowed for the URL /index.html. Apache/1.3.37 Server at www.92csz.com Port 80
Example 2: Use the curl Command in linux to send a POST request to the HTML static page on the nginx server
[root@localhost ~]# curl -d 11=1 http://www.92csz.com/index.htm 405 Not Allowed
405 Not Allowed
nginx/1.2.0
However, in some applications, static files must be able to respond to POST requests.
For Nginx, you can modify the nginc. conf configuration file, change "405 error" to "200 OK", and configure location to solve the problem as follows:
server { listen 80; server_name www.92csz.com; index index.html index.htm index.php; root /opt/htdocs; if (-d $request_filename) { rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent; } error_page 405 =200 @405; location @405 { root /opt/htdocs; } location ~ .*\.php?$ { include conf/fcgi.conf; fastcgi_pass 127.0.0.1:10080; fastcgi_index index.php; } }
Of course, you can also modify the nginx source code to solve the problem.
Modify source code, recompile and install nginx
Edit nginx source code
[root@localhost ~]# vim src/http/modules/ngx_http_static_module.c
Modify: comment out the following section.
/* if (r->method & NGX_HTTP_POST) { return NGX_HTTP_NOT_ALLOWED; } */
Then, recompile and install nginx based on the original compilation parameters.