Apache、IIS、Nginx等绝大多数web服务器,都不允许静态文件响应POST请求,否则会返回“HTTP/1.1 405 Method not allowed”错误。

  例1:用Linux下的curl命令发送POST请求给Apache服务器上的HTML静态页
[root@new-host ~]# 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>
<H1>Method Not Allowed</H1>
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>


  例2:用Linux下的curl命令发送POST请求给Nginx服务器上的HTML静态页
[root@new-host ~]# curl -d 1=1 http://blog.zyan.cc/tech/index.htm
<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/0.5.35</center>
</body>
</html>


  但在有些应用中,需要使静态文件能够响应POST请求。

  对于Nginx,可以修改nginc.conf配置文件,改变“405错误”为“200 ok”,并配置location来解决,方法如下:
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;
   }
}



Tags: , ,



技术大类 » Web服务器 | 评论(44) | 引用(0) | 阅读(124015)
xujie777 Email
2012-5-18 16:50
The choices are likely to be basically countless seeing that louis vuitton outlet occurs with the help of completely new and also incredible concepts once in a while.Louis vuitton Wholesale Monogram Canvas HandbagsLouis Vuitton Collection Beach Handbags louis vuitton bags outlet Damier Canvas HandbagsLouis vuitton Mahina HandbagsLouis Vuitton Monogram Mini Lin HandbagsLouis Vuitton Monogram Multicolore HandbagsLouis vuitton Monogram Vernis HandbagsLouis Vuitton Wholesale Epi Leather HandbagsLouis Vuitton For Men HandbagsLouis Vuitton Damier Canvas WalletsLouis Vuitton Epi Leather WalletsLouis Vuitton Monogram Canvas WalletsLouis Vuitton Monogram Vernis WalleLouis Vuitton ShoesLouis Vuitton Men wallets.As the Authentic Louis Vuitton are so high-priced, so came the louis vuitton handbags outlet.
xujie777 Email
2012-5-18 16:50
coach outlet has become a popular shopping experience for consumers around the world, and a desirable distribution channel for manufacturer's and retailers.Getting your hands on coach outlet store online can be a hefty investment of hundreds of dollars.But do not despair,the Coach Outlet store could be the answer to your prayers.coach outlet online is your smart choice when you want to get the discount Coach accessory. You can find the exact Coach Bags and other accessory you want at a low price that's right for you. My dear friends, let the coach outlet online pave your way into the world of high fashion with their ultimate fashion factory.
xujie123
2012-5-21 11:16
Our online store offers you discounted Designer louis vuitton replica wallet at present. You could find them in desirable quality and price. If you don't mind high class louis vuitton uk, have a good time here.louis vuitton Store Online Handbags can also bring great accuracy as well as practical applicability and fashionable.Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.<br/>
xujie555
2012-5-21 13:40
coach factory outlet uses graceful accessories to match the classical logo of coach, which is the best combination of coach. The handmade coach products?can make you more charming and graceful.coach factory online provides people many coach goods. If you wish to snatch the coach handbag, then this best method is made for that you like for coach discount.coach factory outlet online is a fashion brand to ensure its quality. With designer coach shoulder bags, you will always attract people's attention. The bags will emphasize your personal style and taste.<br/>
xujie333
2012-5-21 15:01
coach outlet online Store guarantee that all the coach handbags offered are own high quality. In addition , all of them are sold at an unexpected low price.If you want to purchase, just visit their website.coach factory outlet is really sizzling kinds of shopping way for you. With the usage of the replica designer coach bags, you can surely be able to change your individual looks in a stunning manner.Coach bags on sale from the coach outlet are cheap or discount prices that you certainly will stand out from the crowd on your next camping trip!<br/>
陈世杰 Email Homepage
2012-7-26 17:29
crydog喜羊羊与灰太狼开心闯龙年
陈世杰 Email Homepage
2012-7-26 17:30
KGUTITYTIOKYKITOYUH8FUGHOTKYJTRGGIKFHNJBBUFIGJGFUGHFGUFJGIFGUUFGINUFGJGJUGFNHTUDFGEYDYEHDFUYFHDGYFGHQWDUFYFFGDHYYHFJHGFUFDYHGHHFGFGFYGFDHGDGHFV GCUHGTRFYGRHTTTTTTRTTYTUHTYTHFUGVHGJFHYFTREHEHEYFHTREYEHYFHGGHFGBFGVJFGHVNFHFHFHFJHVJHFDHDFNJFHFDHFHBHVHCVHVHFGB HHVHHFVHUFHYFDUYFYFUYFGYTGYGHGYYYUYGYYHYHYTGGYYGTGYFYGRTHYTGRTGYFDRGTFTGFRGVFGYGYFFTGYTFFYGDsmile
陈世杰 Email Homepage
2012-7-26 17:32
badanger喜羊羊与灰太狼
陈世杰 Email Homepage
2012-7-26 17:36
killunhappycry
coach88888888 Email
2012-8-13 17:47
If you desire to go to Coach Factory Outlet, but have no idea in which to go, you can research online. It is no doubt that there is drastically information and details about it for the reference.Coach Factory Online are loved by many people, when you walk in the street, you could see many people take coach styles.hat experts claim Coach Outlet Online shopping is in the changes they are available in.Coach Outlet will send you a coupon in the post to use in their upon only after you type a achieve. The Coach bags are customarily somewhat many than the ones in the stores.
GAWETW
2013-1-29 17:35
买轴承就到:www.jkzhoucheng.cn
FQETW
2013-1-29 17:36
买轴承就到:www.jkzhoucheng.cn
HAWEW
2013-3-1 16:16
买轴承就到:www.jkzhoucheng.cn
HAWERW
2013-3-7 14:45
买轴承就到:www.jkzhoucheng.cn
django Email Homepage
2013-11-30 19:46
Uggs Sale the ideal idea Coach Outlet Online  enough time to search for many of reduction Ugg boot. Like big portions? If you began ready your apartment, Coach Outlet  it's always best to consider the most effective way direct to the stage it could be to utilise your inventory throughout Coach Factory Outlet  concern, or maybe you basically won't destination stuff not enough.we're anti- whitening tray because Coach Outlet Online  i will be enjoy just get germ dog breeders
Sexologist in Delhi Email Homepage
2020-11-6 18:48
Victor Homepage
2021-3-8 12:20
There are many reasons that might prevent you from signing in email normally, gmail email login is created to help you solve all sign in problem.
shz Email
2022-6-29 16:51
It’s very informative and you are obviously very knowledgeable in this area. You have opened my eyes to varying views on this topic with interesting and solid content.  online dealings
shz Email
2022-6-29 16:54
Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing.  online dealings
shz Email
2022-6-29 16:57
I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.  online dealings
分页: 2/3 第一页 上页 1 2 3 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]