I can't make a POST if I'm using http://site.com/ as my URL because it redirects me to http://www.site.com/ (adding the www.)
How can I successfully post using CURL with the URL pointing to http://site.com/ even if it redirects me to http://www.site.com/ first?
Here's what I have
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url_to_post);
curl_setopt($ch, CURLOPT_REFERER,$url_to_post);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 2);
$result = curl_exec($ch);
curl_close($ch);
?>