Example 1: Sending a POST request to an HTML static page on the Apache server with the Curl command under Linux
[Email protected] ~]# curl-d 1=1 http://www.sohu.com/index.html
<! DOCTYPE HTML PUBLIC "-//ietf//dtd HTML 2.0//en" >
<HTML><HEAD>
<title>405 Method not allowed</title>
</HEAD><BODY>
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></HTML>
Example 2: Sending a POST request to an HTML static page on the Nginx server using the Curl command under Linux
[Email protected] ~]# curl-d 1=1 http://blog.zyan.cc/tech/index.htm
<body bgcolor= "White" >
<center></body>
In some applications, however, you need to enable a static file to respond to a POST request.
For Nginx, you can modify the nginc.conf configuration file, change "405 error" to "OK", and configure location to solve, the method is as follows:
Server
{
Listen 80;
server_name domain.zyan.cc;
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;
}
} http://zyan.cc/post/337/
Most Web servers, such as Apache, IIS, Nginx, and so on, do not allow static files to respond to post requests, otherwise they will return "http/1.1 405 Method not allowed" error.