title: amazon aws 405 method not allowed when submitting form
body: <p>Recently I have started using Amazon's AWS for web hosting and my HTML contact form does not seem to work anymore, comes back with this error when clicking on the submit button.</p>
  
  <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;405 Method Not Allowed&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;h1&gt;405 Method Not Allowed&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;Code: MethodNotAllowed&lt;/li&gt; &lt;li&gt;Message: The specified method is not allowed against this resource.&lt;/li&gt; &lt;li&gt;Method: POST&lt;/li&gt; &lt;li&gt;ResourceType: OBJECT&lt;/li&gt; &lt;li&gt;RequestId: A8750F9D0586C1E5&lt;/li&gt; &lt;li&gt;HostId: FHjhs//WnJVj8GLE/hKVzkaIBq9DRuhNJxObJ8eARsvAbURpWS87tWivbIsCGnzAeFne9lLLvNI=&lt;/li&gt; &lt;/ul&gt; &lt;hr/&gt; &lt;/body&gt; &lt;/html&gt;
  </code></pre>
  
  <p>my html:</p>
  
  <pre><code>&lt;div class="email-form"&gt;
      &lt;form id="ajax-contact" method="post" action="mailer.php"&gt;
          &lt;div class="flex-input-wrap"&gt;
              &lt;input type="text" placeholder="Name" name="name" id="name" class="flex-input-1" required=""&gt;
              &lt;input type="email" placeholder="Email" name="email" id="email" class="flex-input-2" required=""&gt;
          &lt;/div&gt;
          &lt;textarea type="text" placeholder="Enter text" name="message" id="message" required=""&gt;&lt;/textarea&gt;
          &lt;button type="submit" class="submit-button"&gt;Send message&lt;/button&gt;
      &lt;/form&gt;
      &lt;div id="form-messages"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>js: </p>
  
  <pre><code>$(function () {
      var e = $("#ajax-contact"),
          a = $("#form-messages");
      $(e).submit(function (s) {
          s.preventDefault();
          var r = $(e).serialize();
          $.ajax({
              type: "POST",
              url: $(e).attr("action"),
              data: r
          }).done(function (e) {
              $(a).removeClass("error"), $(a).addClass("success"), $(a).text(e), $("#name").val(""), $("#email").val(""), $("#message").val("")
          }).fail(function (e) {
              $(a).removeClass("success"), $(a).addClass("error"), $(a).text("" !== e.responseText ? e.responseText : "Oops! An error occured and your message could not be sent.")
          })
      })
  });
  </code></pre>
  
  <p>mailer.php file:</p>
  
  <pre><code>&lt;?php
      if ($_SERVER["REQUEST_METHOD"] == "POST") {
          $name = strip_tags(trim($_POST["name"]));
          $name = str_replace(array("\r","\n"),array(" "," "),$name);
          $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
          $message = trim($_POST["message"]);
          if ( empty($name) OR empty($message) OR !filter_var($email, FILTER_VALIDATE_EMAIL)) {
              http_response_code(400);
              echo "Oops! Did you forget to fill out something? Try again.";
              exit;
          }
          $recipient = "myemail@gmail.com";
          $subject = "New email from $name";
          $email_content = "Name: $name\n";
          $email_content .= "Email: $email\n\n";
          $email_content .= "Message:\n$message\n";
          $email_headers = "From: $name &lt;$email&gt;";
          if (mail($recipient, $subject, $email_content, $email_headers)) {
              http_response_code(200);
              echo "Thanks! Your message was sent.";
          } else {
              http_response_code(500);
              echo "Oops! Something went wrong and your message couldn't be sent.";
          }
      } else {
          http_response_code(403);
          echo "There was a problem with your message, please try again.";
      }
  ?&gt;
  </code></pre>
  
  <p>is there some type of setting that i'm missing in AWS?</p>
  
  <p>thanks in advance.</p>