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 @ New-host ~] # Curl-D 1 = 1 http://www.sohu.com/index.HTML
<! Doctype HTML public "-// IETF // dtd html 2.0 // en">
<HTML> <Title> 405 method not allowed </title>
</Head> <body>
<H1> method not allowed The requested method post is not allowed for the URL/index. html. <p>
<HR>
<Address> Apache/1.3.37 server at www.sohu.com port 80 </address>
</Body> Example 2: Use the curl command in Linux to send a POST request to the HTML static page on the nginx Server
[Root @ New-host ~] # Curl-D 1 = 1 http://blog.s135.com/tech/index.htm
<HTML>
<Head> <title> 405 not allowed </title> <Body bgcolor = "white">
<Center> <HR> <center> nginx/0.5.35 </center>
</Body>
</Html>
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 domain.s135.com;
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;
}
}