简体   繁体   中英

403 Error - Forbidden error on making curl request

I have two virtual hosts, xyz.com and abc.com. From xyz.com I'm making curl post call(using PHP) to http://abc.com/test This returns me "403 Error - Forbidden" (http://abc.com/test works fine in browser)

I know this questions sounds quite repeating one. Sorry about that, as I have went through all the solutions given in previous answers, nothing works :-(

  1. My root folders (doc root) in Apache, have 775 permissions.
  2. In httpd.conf my controls are as follows

     Options FollowSymLinks AllowOverride All Order allow,deny Allow from all 
  3. I have also tried adding USERAGENT (of firefox) in code to emulate browser.

I'm not getting whats the exact problem here with Apache. I'm using Apache 2.4

Can some please work out to help on this?

UPDATED Below is code which I'm using for sending request.

$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_URL, 'http://abc.com/test');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, 'a=b&c=d&e=f');
$headers[] = 'Content-Type:application/x-www-form-urlencoded';
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);

Ahh, its solved. Just changed:

Options FollowSymLinks

to:

Options +FollowSymLinks

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM