check the current domain...
Moderator: General Moderators
check the current domain...
Here's what I want to do...
I have two domain names, domain1.com and domain2.com both pointing to the same webspace.
How do I detect which one the user is using?
Basically I to do an if domain = domain1.com then do one load of PHP stuff, else do some different PHP stuff.
I'm just having trouble getting the domain name from the headers - not really sure how that works.
I know it's really easy, but I'm just starting out in PHP and i'm having trouble with the basic syntax.
Thanks
Batfastad
I have two domain names, domain1.com and domain2.com both pointing to the same webspace.
How do I detect which one the user is using?
Basically I to do an if domain = domain1.com then do one load of PHP stuff, else do some different PHP stuff.
I'm just having trouble getting the domain name from the headers - not really sure how that works.
I know it's really easy, but I'm just starting out in PHP and i'm having trouble with the basic syntax.
Thanks
Batfastad
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
Code: Select all
<?php
echo $_SERVER['HTTP_REFERER'];
?>For some reason that doesn't work - printing the referer on the page!
Here's my code, the includes work but the echo command doesn't - am I doing something stupid?
[syntax=php]<?php
include "apsheader.php";
?>
<br />
<br />
<h1>TEST</h1>
<br /><br />
<?php
echo $_SERVER['HTTP_REFERER'];
?>
<?php
include "apsfooter.php";
?>[/syntax]
I know there is no need to escape from PHP after the echo command, but I just copy and pasted from my code to add some HTML in there in a minute.
Any reason why the echo $_SERVER isn't working?
Thanks
Batfastad
Here's my code, the includes work but the echo command doesn't - am I doing something stupid?
[syntax=php]<?php
include "apsheader.php";
?>
<br />
<br />
<h1>TEST</h1>
<br /><br />
<?php
echo $_SERVER['HTTP_REFERER'];
?>
<?php
include "apsfooter.php";
?>[/syntax]
I know there is no need to escape from PHP after the echo command, but I just copy and pasted from my code to add some HTML in there in a minute.
Any reason why the echo $_SERVER isn't working?
Thanks
Batfastad
Last edited by batfastad on Tue May 11, 2004 7:56 am, edited 1 time in total.
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
try
and post results here...
are you simply looking at this page yourself? If you are just typing the address in, I believe referrer will be empty...
Code: Select all
<?php
echo "<pre>";
print_r($_SERVER);
echo"</pre>";
?>are you simply looking at this page yourself? If you are just typing the address in, I believe referrer will be empty...
Oh yeah, I was just typing the address in.
Of course, because noone is referring me to that page, it will be empty
Here are the results...
[C_DOCUMENT_ROOT] => /files/home1/dealerworld/
[DOCUMENT_ROOT] => /usr/local/www/data
[HTTP_ACCEPT] => */*
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_ACCEPT_LANGUAGE] => en-gb
[HTTP_CONNECTION] => Keep-Alive
[HTTP_HOST] => http://www.amdproshow.com
[HTTP_IF_MODIFIED_SINCE] => Fri, 12 Mar 2004 12:21:21 GMT; length=709
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)
[MYU] => http://www.amdproshow.com
[PATH] => /sbin:/bin:/usr/sbin:/usr/bin
[REDIRECT_C_DOCUMENT_ROOT] => /files/home1/dealerworld/
[REDIRECT_DOCUMENT_ROOT] => /files/home1/dealerworld/
[REDIRECT_MYU] => http://www.amdproshow.com
[REDIRECT_SCRIPT_URI] => http://www.amdproshow.com/
[REDIRECT_SCRIPT_URL] => /
[REDIRECT_SERVER_ADMIN] => postmaster@.plus.com
[REDIRECT_SERVER_NAME] => cgi..plus.com
[REDIRECT_STATUS] => 200
[REDIRECT_UNIQUE_ID] => QKDI0sOmgngAAAXqUqU
[REDIRECT_URL] => /
[REMOTE_ADDR] => 81.174.131.4
[REMOTE_PORT] => 11082
[SCRIPT_FILENAME] => /files/home1/dealerworld/index.php
[SCRIPT_URI] => http://www.amdproshow.com/
[SCRIPT_URL] => /
[SERVER_ADDR] => 195.166.130.120
[SERVER_ADMIN] => support@plus.net
[SERVER_NAME] => http://www.amdproshow.com
[SERVER_PORT] => 80
[SERVER_SIGNATURE] =>
Of course, because noone is referring me to that page, it will be empty
Here are the results...
[C_DOCUMENT_ROOT] => /files/home1/dealerworld/
[DOCUMENT_ROOT] => /usr/local/www/data
[HTTP_ACCEPT] => */*
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_ACCEPT_LANGUAGE] => en-gb
[HTTP_CONNECTION] => Keep-Alive
[HTTP_HOST] => http://www.amdproshow.com
[HTTP_IF_MODIFIED_SINCE] => Fri, 12 Mar 2004 12:21:21 GMT; length=709
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)
[MYU] => http://www.amdproshow.com
[PATH] => /sbin:/bin:/usr/sbin:/usr/bin
[REDIRECT_C_DOCUMENT_ROOT] => /files/home1/dealerworld/
[REDIRECT_DOCUMENT_ROOT] => /files/home1/dealerworld/
[REDIRECT_MYU] => http://www.amdproshow.com
[REDIRECT_SCRIPT_URI] => http://www.amdproshow.com/
[REDIRECT_SCRIPT_URL] => /
[REDIRECT_SERVER_ADMIN] => postmaster@.plus.com
[REDIRECT_SERVER_NAME] => cgi..plus.com
[REDIRECT_STATUS] => 200
[REDIRECT_UNIQUE_ID] => QKDI0sOmgngAAAXqUqU
[REDIRECT_URL] => /
[REMOTE_ADDR] => 81.174.131.4
[REMOTE_PORT] => 11082
[SCRIPT_FILENAME] => /files/home1/dealerworld/index.php
[SCRIPT_URI] => http://www.amdproshow.com/
[SCRIPT_URL] => /
[SERVER_ADDR] => 195.166.130.120
[SERVER_ADMIN] => support@plus.net
[SERVER_NAME] => http://www.amdproshow.com
[SERVER_PORT] => 80
[SERVER_SIGNATURE] =>
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA