Rommeo Posted October 31, 2008 Share Posted October 31, 2008 Hi my problem is ; echo <a href=\"".$_SERVER['DOCUMENT_ROOT']."/admin/?module=news\">News</a> is not working. i want it to go to : www.site.com/admin/?module=news but it gives me the link to : http://www.site.com/home/user/public_html/site/admin/?module=pages actually i wanted to use the document_root for page not to affected when i include it whereever i want. How can i fix it ? Or is there any other option ? Thanx in advance. Link to comment https://forums.phpfreaks.com/topic/130941-solved-link-problem/ Share on other sites More sharing options...
thebadbad Posted October 31, 2008 Share Posted October 31, 2008 $_SERVER['SERVER_NAME'] should return something similar to www.site.com. Link to comment https://forums.phpfreaks.com/topic/130941-solved-link-problem/#findComment-679741 Share on other sites More sharing options...
xtopolis Posted November 1, 2008 Share Posted November 1, 2008 Use current domain/path to reload echo "<a href=\"".$_SERVER['PHP_SELF']."/admin/?module=news\">News</a>"; Use directory structure of your www folder include($_SERVER['DOCUMENT_ROOT'].'/path/to/file.ext'); You can use document root for the thing above, but I would say it's easier to use PHP_SELF in that case. Link to comment https://forums.phpfreaks.com/topic/130941-solved-link-problem/#findComment-679809 Share on other sites More sharing options...
thebadbad Posted November 1, 2008 Share Posted November 1, 2008 $_SERVER['PHP_SELF'] The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. Will obviously not work for the domain. Link to comment https://forums.phpfreaks.com/topic/130941-solved-link-problem/#findComment-679894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.