HTTP 错误 403.0 - ModSecurity.操作您无权查看此目录或页面 [英] HTTP Error 403.0 - ModSecurity. Action You do not have permission to view this directory or page

查看:33
本文介绍了HTTP 错误 403.0 - ModSecurity.操作您无权查看此目录或页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ASP.NET 网站并托管在共享主机上,一切正常,但最近我需要通过 cURL 从 php 脚本调用网站的一页,但是在通过 php-cgi.exe 执行 php 脚本时,我得到了以下错误;

I have an ASP.NET Website and hosted on shared hosting and everything is working fine but recently I had requirement to call one page of website from php script via cURL but while executing php script via php-cgi.exe I am getting below error;

HTTP 错误 403.0 - ModSecurity 操作您无权查看此目录或页面.

注意我无需登录网站即可从浏览器浏览该页面.

Note I am able to browse that page from my browser without login to website.

此错误的可能原因是什么,有人可以指导我解决此问题吗?

What can be the possible cause for this error and could someone guide me to resolve this issue?

PHP 脚本

<?php
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "http://<domainname>//<filename>.aspx");
    curl_exec($curl);
    curl_close($curl);
?>

提前致谢!

推荐答案

在分析问题后发现由于未在 cURL 请求中设置用户代理而出现错误.

After Analyzing issue found that error was coming due to user agent was not set in cURL request.

更新了 PHP 脚本;

<?php
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "http://<domainname>//<filename>.aspx");
    curl_setopt($curl,CURLOPT_USERAGENT,"useragentvalue");
    curl_exec($curl);
    curl_close($curl);
?>

这篇关于HTTP 错误 403.0 - ModSecurity.操作您无权查看此目录或页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆