Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com May 18 '11 at 12:16

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

add comment

2 Answers

up vote 4 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
</LimitExcept>
share|improve this answer
    
Already did when I realized I put it in all lower case. :) –  Rob May 18 '11 at 12:58
add comment

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
add comment

Your Answer

 
discard

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.