title: 405 Method Not Allowed IIS 10 Windows Server 2016
body: <p>I am trying to make an API for my website and so far for the GET and POST method it worked, but the DELETE method, I just can't get it to work. I know a lot of people have this issue but I could nowhere find the solution. If anyone can help me, thanks!</p>
  
  <p>PS: Just to be clear, I do not have the WebDav module installed on the Windows Server.</p>
  
  <p>This is my index.php:</p>
  
  <pre><code>&lt;?php
  require_once("DB.php");
  
  $db = new DB("127.0.0.1", "SocialNetwork", "username", "pass");
  
  if ($_SERVER['REQUEST_METHOD'] == "GET") {
  
      if ($_GET['url'] == "auth") {
  
      } else if ($_GET['url'] == "users") {
  
      }
  
  } else if ($_SERVER['REQUEST_METHOD'] == "POST") {
  
      if ($_GET['url'] == "auth") {
              $postBody = file_get_contents("php://input");
              $postBody = json_decode($postBody);
  
              $username = $postBody-&gt;username;
              $password = $postBody-&gt;password;
  
              if ($db-&gt;query('SELECT username FROM users WHERE username=:username', array(':username'=&gt;$username))) {
                      if (password_verify($password, $db-&gt;query('SELECT password FROM users WHERE username=:username', array(':username'=&gt;$username))[0]['password'])) {
                              $cstrong = True;
                              $token = bin2hex(openssl_random_pseudo_bytes(64, $cstrong));
                              $user_id = $db-&gt;query('SELECT id FROM users WHERE username=:username', array(':username'=&gt;$username))[0]['id'];
                              $db-&gt;query('INSERT INTO login_tokens VALUES (0, :token, :user_id)', array(':token'=&gt;sha1($token), ':user_id'=&gt;$user_id));
                              echo '{ "Token": "'.$token.'" }';
                      } else {
                              http_response_code(401);
                      }
              } else {
                      http_response_code(401);
              }
  
      }
  
  } else if ($_SERVER['REQUEST_METHOD'] == "DELETE") {
  if ($_GET['url'] == "auth") {
    if (isset($_GET['token'])) {
      $db-&gt;query('DELETE FROM login_tokens WHERE token=:token', array(':token'=&gt;$_GET['token']));
      echo '{ "Status": "Success" }';
      http_response_code(200);
    } else {
      http_response_code(400);
      echo '{ "Error": "Mal-formed request" }';
    }
    }
  
  } else {
      http_response_code(405);
  }
  ?&gt;
  </code></pre>
  
  <p>And this is my web.config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
  &lt;system.webServer&gt;
      &lt;rewrite&gt;
          &lt;rules&gt;
              &lt;rule name="API"&gt;
                  &lt;match url=".*" /&gt;
                  &lt;action type="Rewrite" url="index.php?url={R:0}" appendQueryString="false" /&gt;
              &lt;/rule&gt;
          &lt;/rules&gt;
      &lt;/rewrite&gt;
      &lt;modules&gt;
          &lt;remove name="WebDAVModule" /&gt;
      &lt;/modules&gt;
      &lt;handlers&gt;
          &lt;remove name="WebDAV" /&gt;
      &lt;/handlers&gt;
      &lt;security&gt;
      &lt;requestFiltering&gt;
          &lt;verbs allowUnlisted="false"&gt;
              &lt;add verb="GET" allowed="true" /&gt;
              &lt;add verb="POST" allowed="true" /&gt;
              &lt;add verb="DELETE" allowed="true" /&gt;
              &lt;add verb="PUT" allowed="true" /&gt;
          &lt;/verbs&gt;
      &lt;/requestFiltering&gt;
  &lt;/security&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p></p>