: 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
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.
More posts by @Ann8826881
1 Comments
Sorted by latest first Latest Oldest Best
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)
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.