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

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.

Leave a Comment