Mobile app version of vmapp.org
Login or Join
Ann8826881

: Restricting post method and authentication to specifc URL paths in Apache .htaccess I shall start with an example. I want to restrict to POST requests only for http://path/to/logical/abc.xml and

@Ann8826881

Posted in: #Apache #Htaccess

I shall start with an example. I want to restrict to POST requests only for path/to/logical/abc.xml and restrict to GET only for path/to/logical/def.xml. How do I put constraints like this as the paths are logical and location directive is not supported in .htaccess?

The actual problem is to set different authentication constraint on diff logical file. Can you tell me as to how do I put a constraint on logical path in the .htaccess file as location directive is not supported in .htaccess.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann8826881

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

I suspect you can probably do this by checking against THE_REQUEST in a RewriteCond (mod_rewrite) directive in .htaccess.
example.com/path/to/logical/abc.xml - POST only example.com/path/to/logical/def.xml - GET ONLY


For our POST only URL, if the request is not a POST request then reject (403 - Forbidden).

RewriteEngine On
RewriteCond ${THE_REQUEST} !^POST [NC]
RewriteRule ^path/to/logical/abc.xml - [F]


For our GET only URL, if the request is not a GET request then reject (403 - Forbidden).

RewriteCond ${THE_REQUEST} !^GET [NC]
RewriteRule ^path/to/logical/def.xml - [F]


(Not tested)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme