开发者

How to limit access to POST request over HTTPS for a single a file in Apache?

开发者 https://www.devze.com 2023-02-03 01:03 出处:网络
I have limited access to a file service.php located in /var/www/sample to HTTPS with following code: <Directory /var/www/sample>

I have limited access to a file service.php located in /var/www/sample to HTTPS with following code:

<Directory /var/www/sample>
        <Files service.php>
                SSLRequireSSL
        </Files>
</Directory>

Now, I would like to limit the 开发者_如何学Pythonaccess only for POST requests. There is a <Limit> directive that should do this but how should I combine it with the above configuration?


you could use mod_rewrite and add this code:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/service.php # if service.php requested
RewriteCond %{REQUEST_METHOD} !^POST$ [NC] # and if its not post
RewriteRule .* - [F] # then block access (403 forbidden)
0

精彩评论

暂无评论...
验证码 换一张
取 消