veerybird Posted August 3, 2009 Share Posted August 3, 2009 I'm testing out my domain on a new host before I update DNS. I'm revising some absolute links using $_SERVER['SERVER_NAME']. I've encountered some weirdness. Because I'm still using XX.XXX.XXX.XXX/~XXXXXX to access my pages and test them, if I use $_SERVER['SERVER_NAME'] for the domain part of the absolute link, I still have to add /~XXXXXX. I think I would have to go back in and remove the /~XXXXXX after DNS propagation. Is there another $_SERVER command I could use instead? I've already played with HTTP_HOST and DOCUMENT_ROOT and some others I found on php.net. So far, $_SERVER['SERVER_NAME']/~XXXXXX gets me what I want, but later I think it will break the links. Link to comment https://forums.phpfreaks.com/topic/168724-_serverserver_name-testing-before-changing-dns/ Share on other sites More sharing options...
Mardoxx Posted August 3, 2009 Share Posted August 3, 2009 doc_root.php <?php define('DOC_ROOT','XXX.XXX.XXX.XXX/~XXXXXX'); ?> in your php files include it: include(doc_root.php); example: instead of echo $_SERVER['SERVER_NAME']."/~XXXXXX"; use echo DOC_ROOT; Link to comment https://forums.phpfreaks.com/topic/168724-_serverserver_name-testing-before-changing-dns/#findComment-890164 Share on other sites More sharing options...
veerybird Posted August 4, 2009 Author Share Posted August 4, 2009 Yes, Mardoxx, I think you are talking about creating an include. doc_root.inc.php. So then I would need to go back into that file and change only one piece of code when I change DNS. That raises another question: Is it possible for a php site to have too many includes? I use them for code that needs to go on almost every page in the same subfolder, but I find myself reluctant to use an include for code that needs to go on one or two pages per subfolder. I think I read something somewhere once about not getting too carried away with them:) Thanks for your reply! Link to comment https://forums.phpfreaks.com/topic/168724-_serverserver_name-testing-before-changing-dns/#findComment-890178 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.