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.

Source: Internet
Author: User
Tags nginx server



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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.