why php PUT route works in apache but not in IIS?












0















I have a php+laravel API application hosted in azure app service.I have the same app hosted in apache in azure as well. The rest end points works properly in apache but in IIS hosted environment all the PUT verbs are failing with 405 (Method Not Allowed) error. I did not try DELETE yet but based on what I am seeing all preflight redirect verbs should be failing.



I spend a week on this, let me first explain what I did so far; I have added following to my web.config



<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains"/>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With,Content-Type" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,DELETE,PUT,PATCH" />
</customHeaders>
</httpProtocol>


With the access-control-allow-methods, I could by pass OPT calls from my front end application.



I tried few of the suggestion mentioned in Laravel 5.1 API Enable Cors answers. Also followed http://codecipher.in/laravel-cors/ so that I could avoid OPT calls from my client side. These changes did allow me to skip OPT calls and able to make my PUT. Unfortunately the PUT calls though it is still failing.



I called the PUT endpoint through postman and I get "The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used." error. In the headers I can see



access-control-allow-methods →POST,GET,OPTIONS,DELETE,PUT,PATCH


but I did see allow as



allow →GET, HEAD, OPTIONS, TRACE


Like I mentioned, the application hosted in Apache works just fine and I would like to give it a try in IIS before I give up and move completely to Apache.



What does IIS uses to prevent calls to PUT verb not to execute?



Thanks










share|improve this question

























  • This shouldn't be limited to Laravel or PHP, but with your IIS configuration, as PUT is an HTTP specification.

    – fyrye
    Nov 21 '18 at 17:32


















0















I have a php+laravel API application hosted in azure app service.I have the same app hosted in apache in azure as well. The rest end points works properly in apache but in IIS hosted environment all the PUT verbs are failing with 405 (Method Not Allowed) error. I did not try DELETE yet but based on what I am seeing all preflight redirect verbs should be failing.



I spend a week on this, let me first explain what I did so far; I have added following to my web.config



<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains"/>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With,Content-Type" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,DELETE,PUT,PATCH" />
</customHeaders>
</httpProtocol>


With the access-control-allow-methods, I could by pass OPT calls from my front end application.



I tried few of the suggestion mentioned in Laravel 5.1 API Enable Cors answers. Also followed http://codecipher.in/laravel-cors/ so that I could avoid OPT calls from my client side. These changes did allow me to skip OPT calls and able to make my PUT. Unfortunately the PUT calls though it is still failing.



I called the PUT endpoint through postman and I get "The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used." error. In the headers I can see



access-control-allow-methods →POST,GET,OPTIONS,DELETE,PUT,PATCH


but I did see allow as



allow →GET, HEAD, OPTIONS, TRACE


Like I mentioned, the application hosted in Apache works just fine and I would like to give it a try in IIS before I give up and move completely to Apache.



What does IIS uses to prevent calls to PUT verb not to execute?



Thanks










share|improve this question

























  • This shouldn't be limited to Laravel or PHP, but with your IIS configuration, as PUT is an HTTP specification.

    – fyrye
    Nov 21 '18 at 17:32
















0












0








0








I have a php+laravel API application hosted in azure app service.I have the same app hosted in apache in azure as well. The rest end points works properly in apache but in IIS hosted environment all the PUT verbs are failing with 405 (Method Not Allowed) error. I did not try DELETE yet but based on what I am seeing all preflight redirect verbs should be failing.



I spend a week on this, let me first explain what I did so far; I have added following to my web.config



<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains"/>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With,Content-Type" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,DELETE,PUT,PATCH" />
</customHeaders>
</httpProtocol>


With the access-control-allow-methods, I could by pass OPT calls from my front end application.



I tried few of the suggestion mentioned in Laravel 5.1 API Enable Cors answers. Also followed http://codecipher.in/laravel-cors/ so that I could avoid OPT calls from my client side. These changes did allow me to skip OPT calls and able to make my PUT. Unfortunately the PUT calls though it is still failing.



I called the PUT endpoint through postman and I get "The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used." error. In the headers I can see



access-control-allow-methods →POST,GET,OPTIONS,DELETE,PUT,PATCH


but I did see allow as



allow →GET, HEAD, OPTIONS, TRACE


Like I mentioned, the application hosted in Apache works just fine and I would like to give it a try in IIS before I give up and move completely to Apache.



What does IIS uses to prevent calls to PUT verb not to execute?



Thanks










share|improve this question
















I have a php+laravel API application hosted in azure app service.I have the same app hosted in apache in azure as well. The rest end points works properly in apache but in IIS hosted environment all the PUT verbs are failing with 405 (Method Not Allowed) error. I did not try DELETE yet but based on what I am seeing all preflight redirect verbs should be failing.



I spend a week on this, let me first explain what I did so far; I have added following to my web.config



<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains"/>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With,Content-Type" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,DELETE,PUT,PATCH" />
</customHeaders>
</httpProtocol>


With the access-control-allow-methods, I could by pass OPT calls from my front end application.



I tried few of the suggestion mentioned in Laravel 5.1 API Enable Cors answers. Also followed http://codecipher.in/laravel-cors/ so that I could avoid OPT calls from my client side. These changes did allow me to skip OPT calls and able to make my PUT. Unfortunately the PUT calls though it is still failing.



I called the PUT endpoint through postman and I get "The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used." error. In the headers I can see



access-control-allow-methods →POST,GET,OPTIONS,DELETE,PUT,PATCH


but I did see allow as



allow →GET, HEAD, OPTIONS, TRACE


Like I mentioned, the application hosted in Apache works just fine and I would like to give it a try in IIS before I give up and move completely to Apache.



What does IIS uses to prevent calls to PUT verb not to execute?



Thanks







laravel azure iis






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 17:33









fyrye

9,04413649




9,04413649










asked Nov 21 '18 at 17:16









unniunni

84




84













  • This shouldn't be limited to Laravel or PHP, but with your IIS configuration, as PUT is an HTTP specification.

    – fyrye
    Nov 21 '18 at 17:32





















  • This shouldn't be limited to Laravel or PHP, but with your IIS configuration, as PUT is an HTTP specification.

    – fyrye
    Nov 21 '18 at 17:32



















This shouldn't be limited to Laravel or PHP, but with your IIS configuration, as PUT is an HTTP specification.

– fyrye
Nov 21 '18 at 17:32







This shouldn't be limited to Laravel or PHP, but with your IIS configuration, as PUT is an HTTP specification.

– fyrye
Nov 21 '18 at 17:32














2 Answers
2






active

oldest

votes


















0














It depends on the server configurations. Some simply decide they do not want to enable such requests for whatever reason they will give you once you ask them. Thing is, not all servers will allow you to have those accessible.
I think a previous post created can help you sort your IIS environment.
If you have no control over the production server or very limited control over its configuration I would advice dropping those and keep the default Requests;






share|improve this answer































    0














    For those facing the same problem, the answer is to add the following section in the web.config file in site/public folder. Do a cache clean and restart the server.



    <system.webServer>
    <handlers>
    <remove name="PHP72_via_FastCGI" />
    <add name="PHP72_via_FastCGI" path="*.php" verb="GET, POST, PUT, DELETE, PATCH" modules="FastCgiModule" scriptProcessor="D:Program Files (x86)PHPv7.2php-cgi.exe" resourceType="Either" requireAccess="Script" />
    </handlers>
    </system.webServer>





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417421%2fwhy-php-put-route-works-in-apache-but-not-in-iis%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      It depends on the server configurations. Some simply decide they do not want to enable such requests for whatever reason they will give you once you ask them. Thing is, not all servers will allow you to have those accessible.
      I think a previous post created can help you sort your IIS environment.
      If you have no control over the production server or very limited control over its configuration I would advice dropping those and keep the default Requests;






      share|improve this answer




























        0














        It depends on the server configurations. Some simply decide they do not want to enable such requests for whatever reason they will give you once you ask them. Thing is, not all servers will allow you to have those accessible.
        I think a previous post created can help you sort your IIS environment.
        If you have no control over the production server or very limited control over its configuration I would advice dropping those and keep the default Requests;






        share|improve this answer


























          0












          0








          0







          It depends on the server configurations. Some simply decide they do not want to enable such requests for whatever reason they will give you once you ask them. Thing is, not all servers will allow you to have those accessible.
          I think a previous post created can help you sort your IIS environment.
          If you have no control over the production server or very limited control over its configuration I would advice dropping those and keep the default Requests;






          share|improve this answer













          It depends on the server configurations. Some simply decide they do not want to enable such requests for whatever reason they will give you once you ask them. Thing is, not all servers will allow you to have those accessible.
          I think a previous post created can help you sort your IIS environment.
          If you have no control over the production server or very limited control over its configuration I would advice dropping those and keep the default Requests;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 17:20









          Diogo SantoDiogo Santo

          48818




          48818

























              0














              For those facing the same problem, the answer is to add the following section in the web.config file in site/public folder. Do a cache clean and restart the server.



              <system.webServer>
              <handlers>
              <remove name="PHP72_via_FastCGI" />
              <add name="PHP72_via_FastCGI" path="*.php" verb="GET, POST, PUT, DELETE, PATCH" modules="FastCgiModule" scriptProcessor="D:Program Files (x86)PHPv7.2php-cgi.exe" resourceType="Either" requireAccess="Script" />
              </handlers>
              </system.webServer>





              share|improve this answer




























                0














                For those facing the same problem, the answer is to add the following section in the web.config file in site/public folder. Do a cache clean and restart the server.



                <system.webServer>
                <handlers>
                <remove name="PHP72_via_FastCGI" />
                <add name="PHP72_via_FastCGI" path="*.php" verb="GET, POST, PUT, DELETE, PATCH" modules="FastCgiModule" scriptProcessor="D:Program Files (x86)PHPv7.2php-cgi.exe" resourceType="Either" requireAccess="Script" />
                </handlers>
                </system.webServer>





                share|improve this answer


























                  0












                  0








                  0







                  For those facing the same problem, the answer is to add the following section in the web.config file in site/public folder. Do a cache clean and restart the server.



                  <system.webServer>
                  <handlers>
                  <remove name="PHP72_via_FastCGI" />
                  <add name="PHP72_via_FastCGI" path="*.php" verb="GET, POST, PUT, DELETE, PATCH" modules="FastCgiModule" scriptProcessor="D:Program Files (x86)PHPv7.2php-cgi.exe" resourceType="Either" requireAccess="Script" />
                  </handlers>
                  </system.webServer>





                  share|improve this answer













                  For those facing the same problem, the answer is to add the following section in the web.config file in site/public folder. Do a cache clean and restart the server.



                  <system.webServer>
                  <handlers>
                  <remove name="PHP72_via_FastCGI" />
                  <add name="PHP72_via_FastCGI" path="*.php" verb="GET, POST, PUT, DELETE, PATCH" modules="FastCgiModule" scriptProcessor="D:Program Files (x86)PHPv7.2php-cgi.exe" resourceType="Either" requireAccess="Script" />
                  </handlers>
                  </system.webServer>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 22 '18 at 7:00









                  unniunni

                  84




                  84






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417421%2fwhy-php-put-route-works-in-apache-but-not-in-iis%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      'app-layout' is not a known element: how to share Component with different Modules

                      android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                      WPF add header to Image with URL pettitions [duplicate]