Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How should I allow only GET request to access all the files and script from my server using htaccess?

My web server is Apache

share|improve this question

migrated from May 18 '11 at 12:16

This question came from our site for professional and enthusiast programmers.

up vote 7 down vote accepted

You may also want to have a look at the Apache Limit and/or LimitExcept directives. Rewrite rules give you the opportunity to put up a custom error page though.

I believe something like this might work:

<LimitExcept GET HEAD>
  Order Allow,Deny
  Deny from all
share|improve this answer
Already did when I realized I put it in all lower case. :) – Rob May 18 '11 at 12:58

How about this?

> RewriteEngine On
> RewriteCond %{REQUEST_METHOD} !=GET
> RewriteRule ^.*$ /path/to
share|improve this answer
This will redirect non-GET requests to another path on the server; it doesn't 'disallow' them. Though you could redirect them to an error page and use the [R=406] on the end of the RewriteRule line. – Chris S May 18 '11 at 12:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.