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

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

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

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

When an application running on Microsoft IIS returns an HTTP 405 error—specifically "The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used"—it usually signals that the server configuration explicitly forbids the requested action. While this often points to a misconfiguration in web.config, a scenario where one specific form fails on a single IIS 6.0 instance while identical forms work perfectly elsewhere suggests the issue lies deeper than a simple global setting.

The error occurs when the request handler for a PHP file is configured to reject POST requests, yet other pages in the same application accept them. In IIS 6.0, this behavior is controlled by the allowedVerbs property within the module configuration. By default, PHP handlers might be restricted to GET, but if the configuration allows GET for some files and blocks POST for others, it indicates a divergence in how the specific file or its directory is processed.

To resolve this without direct server access, you must provide replacement files that enforce a more permissive handler configuration. The most effective approach is to ensure the PHP handler explicitly lists POST (and typically GET, PUT, DELETE) within its allowedVerbs. In an IIS 6 context, this is often managed via the web.config file in the application root or specifically for the failing script.

A critical detail when addressing IIS 405 errors is ensuring the handler mapping itself is not missing entirely. If a PHP file lacks a proper handler mapping, IIS may default to treating it as static content or a generic page, which often defaults to GET-only behavior unless overridden. However, if other PHP files in the same directory work, the handler mapping exists for that extension. The problem likely stems from a specific directive restricting verbs for that single file path.

When sending replacement files, consider the following implementation detail: ensure the web.config includes a <location> block that explicitly defines the verb permissions for the failing script. For example:

<configuration>
  <system.webServer>
    <handlers>
      <!-- Ensure PHP is mapped correctly -->
      <add name="PHP-5" path="*.php" verb="*" executable="true" />
    </handlers>
    <httpHandlers>
      <!-- Fallback if using older IIS 6 defaults -->
      <verbMap verb="POST" /> 
    </httpHandlers>
  </system.webServer>
</configuration>

While modern PHP environments often rely on the global handler mapping, legacy setups like PHP 5.2.9 paired with IIS 6.0 require explicit attention to these legacy directives. If the application uses a custom .htaccess file (though less common on IIS), ensure it does not inadvertently strip POST support for that specific route.

Another potential pitfall is the presence of security modules or URL rewriting rules that might be applied conditionally. Some security configurations block POST requests to certain endpoints if they detect unusual patterns, though this usually results in 403 Forbidden rather than 405. The 405 specifically indicates the method is known but disallowed by the handler configuration.

If the form uses a specific action attribute pointing to index.php, verify that no rewrite rules are interfering with that specific path. In IIS, rewriting can sometimes mask the original verb or redirect requests in ways that trigger verb restrictions if the target resource isn't configured to accept the new method.

By providing files that explicitly permit POST verbs in their handler definitions, you bypass the restrictive default behavior of the legacy PHP module on IIS 6.0. This approach ensures compatibility across different server configurations while maintaining security through explicit allowlists rather than broad defaults. Developers should always audit the allowedVerbs property when troubleshooting isolated 405 errors on IIS, especially in environments where global settings appear correct but individual files behave differently.

Our network