HTTP Error 403.0 - ModSecurity. Action You do not have permission to view this directory or page

北慕城南 提交于 2019-12-12 00:43:40

问题


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 Error 403.0 - ModSecurity Action You do not have permission to view this directory or page.

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 Script

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

Thanks in advance!


回答1:


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

Updated PHP script;

<?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);
?>


来源:https://stackoverflow.com/questions/37011704/http-error-403-0-modsecurity-action-you-do-not-have-permission-to-view-this-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!