|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-11 00:07 UTC] 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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
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"; ?>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);