jackr1909 Posted June 26, 2011 Share Posted June 26, 2011 Hi all, I am getting a blank page with this code <?php $page = $_SERVER['PHP_SELF']; if ($page == "http://www.example.com"); { header('Location: /example.com'); ?> Thanks in advance Jack Quote Link to comment https://forums.phpfreaks.com/topic/240432-php-if-url/ Share on other sites More sharing options...
floridaflatlander Posted June 26, 2011 Share Posted June 26, 2011 maybe this well help $page = dirname($_SERVER['PHP_SELF']); Quote Link to comment https://forums.phpfreaks.com/topic/240432-php-if-url/#findComment-1234946 Share on other sites More sharing options...
jackr1909 Posted June 26, 2011 Author Share Posted June 26, 2011 Hi, sorry, it didn't work. I still got the blank white page thanks Quote Link to comment https://forums.phpfreaks.com/topic/240432-php-if-url/#findComment-1234948 Share on other sites More sharing options...
floridaflatlander Posted June 26, 2011 Share Posted June 26, 2011 Where are you getting a blank page? At http://www.example.com or on the file with the code? Also take the if statement out or comment it out and make an echo statement and see what you get. "I think" it would be something like "/example.com" not http://www.example.com Quote Link to comment https://forums.phpfreaks.com/topic/240432-php-if-url/#findComment-1234951 Share on other sites More sharing options...
WebStyles Posted June 26, 2011 Share Posted June 26, 2011 PHP_SELF will return the page's name, not the full domain name. (I'm guessing you have several domains pointing to the same place, and you want to send each one to the correct folder?) try something like: <?php $serverName = $_SERVER['SERVER_NAME']; header("Location: /".$serverName."/"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/240432-php-if-url/#findComment-1234988 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.