此分发未配置为允许HTTP请求

时间:2015-07-06 19:07:43

标签: php html forms amazon-web-services https

This distribution is not configured to allow the HTTP request method that was used for this request. The distribution supports only cachable requests. 

我已将网站配置为仅在令人惊叹的云端接受https。 简而言之,您有一个php登录表单,并在成功登录后重定向用户,如下所示:

 if(isset($_POST['login'])){

[...]
        echo "<script>window.open('coursePayment.php?crs_id=$crs_id','_self')</script>";

以下是表格:

 <form style="margin-top:-20px" method='post' action='' class='form-horizontal' role='form'>
       <input type="hidden" id="couponCodeLogin" name="couponCodeLogin">
        <input type="hidden" id="couponCodeLoginAmount" name="couponCodeLoginAmount">
<br><br>
 <div class="group">      
            <input type='text' class='form-control' name='email' required>
      <span class="highlight"></span>
      <span class="bar"></span>
      <label>Email</label>
    </div>

    <div class="group">      
            <input type='password' class='form-control' name='pass' required>
      <span class="highlight"></span>
      <span class="bar"></span>
      <label>Password</label>
    </div>


            <h5 style="color:#FF6400; cursor:context-menu; margin-top:0px" class="displayForgotPassword">Forgot your password? Click here to retrieve it.</h5><br>
            <input type='submit' id='moreInfoButton' name='login' value='Continue' class='btn btn-danger'>                               
          </form> 

3 个答案:

答案 0 :(得分:18)

该错误试图告诉您的是您无法使用POST。猜测可缓存意味着在这种情况下GET。您需要继续配置云前端以允许&#34;上传请求&#34;像POST,PUT等。在这种情况下,请求将转到Cloudfront使用的原点。

Aws docs: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating.html

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating-console.html

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html

在上一个链接中查找允许的HTTP方法。

答案 1 :(得分:13)

最后得到了我们可以更改http方法的网页。 enter image description here

谢谢, Sanjay Salunkhe

答案 2 :(得分:0)

发生此错误是因为CloudFront没有配置为接受正在发送的HTTP请求(例如POSTPATCH)。

要修复此问题,请更改CloudFront分配设置以接受所有HTTP方法。

要执行此操作,请单击CloudFront发行版的Behaviors标签,选择默认行为,单击Edit,将Allowed HTTP Methods更改为GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE,然后单击{右下角的{1}}保存更改。

Change Allowed HTTP Methods in a CloudFront distribution

您的CloudFront发行版可能要花费几分钟才能传播更改。