HTTP错误403.0-ModSecurity。操作您无权查看此目录或页面 [英] HTTP Error 403.0 - ModSecurity. Action You do not have permission to view this directory or page
问题描述
我有一个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屋!