I am using php curl, my code is working for other websites but when i request for this url https://i.local.ch/#q?q=manager&origin=&rid=ac8EV&sort=relevance
it returns:
405 Not Allowed nginx
Note: SSl is active on my domain
include "simple_html_dom.php";
$url="https://i.local.ch/#q?q=manager&origin=&rid=ac8EV&sort=relevance";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
$info = curl_getinfo($ch);
print_r( $info );
echo var_dump($server_output);
HTTP 405 errors are caused when an HTTP method is not allowed by a web server for a requested URL.
Make same request from browser and check request headers. Make sure you are using correct method get, post or put while making request. Also check if any additional headers are sent with request as some urls only allowed from ajax request and you can achieve this by adding proper headers with request.
You can send additional headers using below method
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"Accept-Charset" => "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Keep-Alive" => "115",
"Connection" => "keep-alive",
"X-Requested-With" => "XMLHttpRequest"
));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.