What causes an HTTP 405 “invalid method (HTTP verb)” error when POSTing a form to PHP on IIS?

后端 未结 11 1168
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 12:05

I have one form in a PHP (5.2.9-1) application that causes IIS (Microsoft-IIS/6.0) to throw the following error when POSTed:

The page you are looking

11条回答
  •  迷失自我
    2020-11-29 12:30

    I managed to get FTP access to the customer's server and so was able to track down the problem.

    After the form is POSTed, I authenticate the user and then redirect to the main part of the app.

    Util::redirect('/apps/content');
    

    The error was occurring not on the posting of the form, but on the redirect immediately following it. For some reason, IIS was continuing to presume the POST method for the redirect, and then objecting to the POST to /apps/content as it's a directory.

    The error message never indicated that it was the following page that was generating the error - thanks Microsoft!

    The solution was to add a trailing slash:

    Util::redirect('/apps/content/');
    

    IIS could then resolve the redirect to a default document as is no longer attempting to POST to a directory.

提交回复
热议问题