Megami Posted December 27, 2010 Share Posted December 27, 2010 Hi all, I have a project for a while. Since the games get their English release (Pokémon Black and White), I'd like to make content differ between domain names, but at the same time, it needs to be in the same files. For example: If someone accesses the site, using HiunCity.com, they'll need to see this: "Hiun City, the largest city in the Isshu Region, has finally been opened!" But if they access the site, using CasteliaCity.com, it has to be: "Castelia City, the largest city in the Unova Region, has finally been opened!" I'm sure there's a PHP Code for this. Thanks in advance! 女神 Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/ Share on other sites More sharing options...
requinix Posted December 27, 2010 Share Posted December 27, 2010 You can use $_SERVER["HTTP_HOST"] to see which domain name the user went to. Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151907 Share on other sites More sharing options...
Megami Posted December 27, 2010 Author Share Posted December 27, 2010 >>requinix No, I mean that the content differs from used domains, not to see which domain has been used. If you now go to one of the 2 domains, the site is identical to each other. What I want is, make the Japanese names viewable for Hiun City, and the English names viewable for Castelia City. I know it's something with "If/Else". Sorry, I'm a total n00b about PHP, I know HTML better. Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151908 Share on other sites More sharing options...
Rifts Posted December 27, 2010 Share Posted December 27, 2010 $_SERVER["HTTP_HOST"] and use if/else if ($_SERVER["HTTP_HOST"] == HiunCity.com { do Japanese stuff } else { do english stuff } Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151910 Share on other sites More sharing options...
Megami Posted December 27, 2010 Author Share Posted December 27, 2010 >>Rifts It didn't work. My code is: <?php $_SERVER["HTTP_HOST"] ?> <h2>Welcome</h2> <p>Welcome to the site.<br /> <?php if ($_SERVER["HTTP_HOST"] == hiuncity.com) { print "Hiun City, the largest city in the Isshu Region, has finally been opened!<br />" } elseif ($_SERVER["HTTP_HOST"] == www.hiuncity.com) { print "Hiun City, the largest city in the Isshu Region, has finally been opened!<br />" } elseif ($_SERVER["HTTP_HOST"] == www.casteliacity.com) { print "Castelia City, the largest city in the Unova Region, has finally been opened!<br />" } else { print "Castelia City, the largest city in the Unova Region, has finally been opened!<br />" } ?> We finished the site, so no big things will happen, from now on.<br /> We keep developing this project, and The CW-Network gives you Best Wishes.<br /> You're always welcome, visiting our city, working in our city, living in our city, or whatever you like!</p> <audio autoplay="autoplay" loop="loop"> <source src="files/bgm/hiun.ogg" type="audio/ogg" /> <source src="files/bgm/hiun.mp3" type="audio/mpeg" /> Your browser does not support the audio element. </audio> I also tried "echo" instead of "print", but it gave me the same results. Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151912 Share on other sites More sharing options...
Rifts Posted December 27, 2010 Share Posted December 27, 2010 try echoing $_SERVER["HTTP_HOST"] and seeing what it is you might need to add http:// Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151913 Share on other sites More sharing options...
BlueSkyIS Posted December 27, 2010 Share Posted December 27, 2010 you must quote strings. the code as posted should not parse and you should get a parse error. a corrected line: if ($_SERVER["HTTP_HOST"] == 'hiuncity.com') { Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151914 Share on other sites More sharing options...
BlueSkyIS Posted December 27, 2010 Share Posted December 27, 2010 also: the following line doesn't do anything, so you should remove it: <?php $_SERVER["HTTP_HOST"] ?> also: All commands must be followed by a semi-colon. print "Hiun City, the largest city in the Isshu Region, has finally been opened!<br />"; if you aren't seeing a parse error when you try to run that code, you probably have error_reporting turned off. try to turn it on by putting these lines as the first lines in your file: ini_set('error_reporting',E_ALL); error_reporting(-1); Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151915 Share on other sites More sharing options...
Megami Posted December 27, 2010 Author Share Posted December 27, 2010 >>Rifts The "echo $_SERVER["HTTP_HOST"]" part worked, but adding "http://" gave no difference. >>BlueSkyIS It's working, but not like it suppose to be. Now all the text is for Castelia (Hiun also desplays Castelia text). Code is now: <h2>Welcome</h2> <p>Welcome to the site.<br /> <?php if ($_SERVER["HTTP_HOST"] == 'http://hiuncity.com') { print "Hiun City, the largest city in the Isshu Region, has finally been opened!<br />"; } else { print "Castelia City, the largest city in the Unova Region, has finally been opened!<br />"; } ?> We finished the site, so no big things will happen, from now on.<br /> We keep developing this project, and The CW-Network gives you Best Wishes.<br /> You're always welcome, visiting our city, working in our city, living in our city, or whatever you like!</p> <audio autoplay="autoplay" loop="loop"> <source src="files/bgm/hiun.ogg" type="audio/ogg" /> <source src="files/bgm/hiun.mp3" type="audio/mpeg" /> Your browser does not support the audio element. </audio> Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151919 Share on other sites More sharing options...
requinix Posted December 27, 2010 Share Posted December 27, 2010 >>Rifts The "echo $_SERVER["HTTP_HOST"]" part worked, but adding "http://" gave no difference. Only the hostname. No protocol (that's the "http://" bit). if ($_SERVER["HTTP_HOST"] == 'hiuncity.com') You may need to account for a www. subdomain too. Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151925 Share on other sites More sharing options...
Megami Posted December 27, 2010 Author Share Posted December 27, 2010 >>requinix Now it's working correctly! Now I have a final question for today (which is just 5 minutes left until the next day): I know there is a variable for PHP to add subdomains automatically, but I forgot how it was called. Quote Link to comment https://forums.phpfreaks.com/topic/222759-content-depending-on-used-domain/#findComment-1151927 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.