如何限制 Apache 中单个文件通过 HTTPS 访问 POST 请求?

发布于 2024-10-10 01:03:52 字数 430 浏览 0 评论 0原文

我使用以下代码将位于 /var/www/sample 中的文件 service.php 的访问限制为 HTTPS:

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

现在,我想限制仅对 POST 的访问请求。有一个 指令应该执行此操作,但是我应该如何将它与上述配置结合起来?

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 access only for POST requests. There is a <Limit> directive that should do this but how should I combine it with the above configuration?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡離愁欲言轉身 2024-10-17 01:03:52

您可以使用 mod_rewrite 并添加以下代码:

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)

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文