Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8882881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:41:05+00:00 2026-06-14T20:41:05+00:00

I have been looking around for ways to deny all HTTP methods but POST.

  • 0

I have been looking around for ways to deny all HTTP methods but POST. Yes i realize this might not prevent much but i would like to make it work. I came across a way to deny all but post using the .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} !^POST
RewriteRule ^.*$ /home/user/public_html/folder/bad_request.php

Now in my iphone app i have the following code which POST’s data to the website:

NSString *post_length = [NSString stringWithFormat:@"%d",[post_data length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://folder.domain.com/"]];
[request setHTTPMethod:@"POST"];
[request setValue:post_length forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:post_data];

When i run this code with my current .htaccess as shown above i get the bad_request page as if i wasnt POSTing data but if i change the .htaccess rule to !^GET i can visit it in the browser and gain access but when i post with the iPhone code i get denied…so that works backwards. Does anyone have an idea why it wont work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:41:06+00:00Added an answer on June 14, 2026 at 8:41 pm

    Ok so after trying with no success i finally decided to incorporate a portion of your suggested .htaccess code along with some .php. I have the .htaccess file get the request method and send it to the index.php, the index.php file then says if its == ‘POST’ do something else do something else and it works.

    .htaccess

    RewriteEngine On
    RewriteRule ^(.*) index.php?request=%{REQUEST_METHOD} [L,QSA]
    

    index.php

    if ($_GET['request'] == 'POST') {
    
    } else {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking around the web for this but cannot really find a
I have been looking around for an answer to this, but couldn't really find
I have been looking around ocn Google and Stackoverflow but haven't found what I
I have been looking around at different ways to connect to URLs and there
I have been looking around for hours on how to do this, I think
Been looking around stackoverflow and google for ways to solve this issue im having
Have been looking around for a solution to this and have found some help
I have been looking around for an answer to my question but couldn't find
I have been looking around online at how to post a UIImage to the
I have been looking around for a while on google but no fruitful results.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.