Using mod_rewrite to block access based on REQUEST_METHOD + HTTP header

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I want to use mod_rewrite to return 403 Forbidden when the REQUEST_METHOD is GET and when a specific custom header is missing. But I want to allow through requests with the OPTIONS verb even if that custom header is missing.



This is what I am using currently:



RewriteEngine On
RewriteCond %REQUEST_METHOD =GET
RewriteCond %HTTP:SomeHeader ^$
RewriteRule .* - [F]


The GET behavior seems to be working fine (if header supplied I get back 200, without it I get 403). But I am also seeing that same behavior for OPTIONS (403 unless I provide header, then 200).



It seems like when the HTTP verb is OPTIONS the first RewriteCond should be failing, but somehow it seems like it is "passing" and continuing on with the other condition + rule.



Any thoughts on what is going on here? Thanks in advance!









share







New contributor




Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    0
    down vote

    favorite












    I want to use mod_rewrite to return 403 Forbidden when the REQUEST_METHOD is GET and when a specific custom header is missing. But I want to allow through requests with the OPTIONS verb even if that custom header is missing.



    This is what I am using currently:



    RewriteEngine On
    RewriteCond %REQUEST_METHOD =GET
    RewriteCond %HTTP:SomeHeader ^$
    RewriteRule .* - [F]


    The GET behavior seems to be working fine (if header supplied I get back 200, without it I get 403). But I am also seeing that same behavior for OPTIONS (403 unless I provide header, then 200).



    It seems like when the HTTP verb is OPTIONS the first RewriteCond should be failing, but somehow it seems like it is "passing" and continuing on with the other condition + rule.



    Any thoughts on what is going on here? Thanks in advance!









    share







    New contributor




    Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I want to use mod_rewrite to return 403 Forbidden when the REQUEST_METHOD is GET and when a specific custom header is missing. But I want to allow through requests with the OPTIONS verb even if that custom header is missing.



      This is what I am using currently:



      RewriteEngine On
      RewriteCond %REQUEST_METHOD =GET
      RewriteCond %HTTP:SomeHeader ^$
      RewriteRule .* - [F]


      The GET behavior seems to be working fine (if header supplied I get back 200, without it I get 403). But I am also seeing that same behavior for OPTIONS (403 unless I provide header, then 200).



      It seems like when the HTTP verb is OPTIONS the first RewriteCond should be failing, but somehow it seems like it is "passing" and continuing on with the other condition + rule.



      Any thoughts on what is going on here? Thanks in advance!









      share







      New contributor




      Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I want to use mod_rewrite to return 403 Forbidden when the REQUEST_METHOD is GET and when a specific custom header is missing. But I want to allow through requests with the OPTIONS verb even if that custom header is missing.



      This is what I am using currently:



      RewriteEngine On
      RewriteCond %REQUEST_METHOD =GET
      RewriteCond %HTTP:SomeHeader ^$
      RewriteRule .* - [F]


      The GET behavior seems to be working fine (if header supplied I get back 200, without it I get 403). But I am also seeing that same behavior for OPTIONS (403 unless I provide header, then 200).



      It seems like when the HTTP verb is OPTIONS the first RewriteCond should be failing, but somehow it seems like it is "passing" and continuing on with the other condition + rule.



      Any thoughts on what is going on here? Thanks in advance!







      mod-rewrite





      share







      New contributor




      Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 3 mins ago









      Trevor

      1




      1




      New contributor




      Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Trevor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          );



          );






          Trevor is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f480264%2fusing-mod-rewrite-to-block-access-based-on-request-method-http-header%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Trevor is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          Trevor is a new contributor. Be nice, and check out our Code of Conduct.












          Trevor is a new contributor. Be nice, and check out our Code of Conduct.











          Trevor is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f480264%2fusing-mod-rewrite-to-block-access-based-on-request-method-http-header%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?