ajsuk Posted July 8, 2006 Share Posted July 8, 2006 Hey there, as you'll guess from my post count I'm as noob as they come but I'll try to be as clear as pos. ;)I've recently started getting in to learning PHP and have modified my website to work using the php include linking functions...I managed to get it working well but as soon as I tried to use it with my subdomains I hit a brick wall. :(If you imagine my website is sports.com. Here is what I'd like to do:If somebody visits http://football.sports.com, I would like them to be redirected to http://sports.com?pageid=baseball BUT without the new address being visible, so http://football.sports.com still appears in their browser address bar.Is this posible?Thanks in advance for any help you can give!Andy. Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/ Share on other sites More sharing options...
micah1701 Posted July 8, 2006 Share Posted July 8, 2006 the first part is simple enough[code]<?php$domainParts = explode(".",$_SERVER['HTTP_HOST']);if($domainParts[0] == "football"){header("Location: http://sports.com?pageid=baseball");}?>[/code]although, why do you want people looking for football to go to a baseball page?anyway, the other part will either require using HTML Frames (where you use a 100% sized frame inside your original domain name to make it look like you never left that page)OR, instead of forwarding to the new page altogether, use an include() in your PHP code.on the page found at football.sports.comuse the script I gave above but change it like this:[code]<?php$domainParts = explode(".",$_SERVER['HTTP_HOST']);if($domainParts[0] == "football"){$pageid = "baseball";include("filename.php");//the filename of the page at http://sports.com}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/#findComment-54657 Share on other sites More sharing options...
ajsuk Posted July 8, 2006 Author Share Posted July 8, 2006 [quote author=micah1701 link=topic=99835.msg393412#msg393412 date=1152326670]although, why do you want people looking for football to go to a baseball page?[/quote]hehe, yeah, bad example...But anyway thanks very much for the speedy reply, will give it a try and get post back. ;) Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/#findComment-54666 Share on other sites More sharing options...
ajsuk Posted July 8, 2006 Author Share Posted July 8, 2006 Ok I tried the second example but without much success. :(I changed the "football" subdomain and the "baseball" pageid to what they really needed to be.Then changed the "filename.php" to "index.php" which is what the filename is there, ofcourse, but this didn't work. :(I guessed I'd perhaps have to put in the full URL or Path to the index file... Both of these did display the index.php file but it didn't set the pageid to "baseball". Any idea what could be wrong?Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/#findComment-54758 Share on other sites More sharing options...
Daniel0 Posted July 8, 2006 Share Posted July 8, 2006 [code]<?phpecho file_get_contents("http://sports.com/?pageid=baseball");?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/#findComment-54774 Share on other sites More sharing options...
ajsuk Posted July 8, 2006 Author Share Posted July 8, 2006 hehe, well thats much more simple, and works! Thankies very much! Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/#findComment-54789 Share on other sites More sharing options...
ajsuk Posted July 14, 2006 Author Share Posted July 14, 2006 hmm, well while the file_get_contents worked to an extent it doesn't then seem to want to continue on when I link from that page. It justs sticks to what I linked the file_get_contents echo to includ...Is there a better way to do this, anyone?Thanks again for any help. Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/#findComment-57962 Share on other sites More sharing options...
ajsuk Posted July 14, 2006 Author Share Posted July 14, 2006 any way at all? ??? Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/#findComment-58128 Share on other sites More sharing options...
ajsuk Posted July 17, 2006 Author Share Posted July 17, 2006 *bump* :( Quote Link to comment https://forums.phpfreaks.com/topic/13992-php-include-linking-with-subdomains/#findComment-59621 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.