FlyingIsFun1217 Posted June 2, 2008 Share Posted June 2, 2008 Is there an easy way to find the current working directory relative to the external server address? For example, if I had 'check.php' in '/loser/directory/', is there a way to get php to return 'http://www.myplace.net/loser/directory/'? FlyingIsFun1217 Link to comment https://forums.phpfreaks.com/topic/108320-solved-getting-relative-url/ Share on other sites More sharing options...
soycharliente Posted June 2, 2008 Share Posted June 2, 2008 <?php echo $_SERVER['PHP_SELF']; ?> That will give you the path to the file from the root directory. It will not include any extra variables tacked onto the URL (index.php?a=1&b=2). For that, use: <?php echo $_SERVER['REQUEST_URI']; ?> Link to comment https://forums.phpfreaks.com/topic/108320-solved-getting-relative-url/#findComment-555354 Share on other sites More sharing options...
FlyingIsFun1217 Posted June 2, 2008 Author Share Posted June 2, 2008 Perfect! Now all I need to do is tack that onto the base URL! Thanks so much! Solved! FlyingIsFun1217 Link to comment https://forums.phpfreaks.com/topic/108320-solved-getting-relative-url/#findComment-555524 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.