Edit report at http://bugs.php.net/bug.php?id=31481&edit=1
ID: 31481
Comment by: ktcox at rogers dot com
Reported by: jason at merchant dot to
Summary: curl isn't following redirects with a relative path
Status: No Feedback
Type: Bug
Package: HTTP related
Operating System: Windows XP Pro
PHP Version: 4.3.10
New Comment:
I guess that makes sence.
But is there anyway to curl or any way to http post to a completely
offline page?
The following script might help those who would wish to use a relitive
url. It takes the url of the current script and chops off the file name
giving you the CWD from the server point of view.
<?php
$backwards = strrev($_SERVER['PHP_SELF']); // Get the CWD form the
web
point of view.
do
{
$char = substr($backwards, 0, 1);
$backwards = substr($backwards, 1);
} while (!( $char == '/' )) ;
$dir = "http://$_SERVER[SERVER_NAME]" . strrev($backwards);
?>
then you would use
curl_init($dir/script.php);
Previous Comments:
------------------------------------------------------------------------
[2010-06-14 01:48:59] [email protected]
Those are not supposed to work. curl_init() takes a URL. None of the
arguments
in your example that don't work are URLs.
------------------------------------------------------------------------
[2010-06-14 00:15:42] ktcox at rogers dot com
This Works
<?php
$addpage = curl_init('http://localhost/updateindex.php');
$page = curl_exec($addpage);
curl_close($addpage);
echo "$page";
?>
The following don't work.
<?php
$addpage = curl_init('/updateindex.php');
$page = curl_exec($addpage);
curl_close($addpage);
echo "$page";
?>
<?php
$addpage = curl_init('updateindex.php');
$page = curl_exec($addpage);
curl_close($addpage);
echo "$page";
?>
<?php
$addpage = curl_init('./updateindex.php');
$page = curl_exec($addpage);
curl_close($addpage);
echo "$page";
?>
------------------------------------------------------------------------
[2005-01-31 22:34:22] [email protected]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
------------------------------------------------------------------------
[2005-01-11 04:54:37] [email protected]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.
If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2005-01-11 00:07:59] jason at merchant dot to
Description:
------------
I am grabbing an https:// page using curl and that page redirects using
a relative path like "/page1.php". curl is failing to follow this path.
I have tried replacing the relative path with an absolute path on the
page I'm grabbing and that worked so I know the problem lies in the
relative path redirection.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=31481&edit=1