I have two domains which are similar,
mysite1.com and mysite2.com
I only have one hosting account and I have the other site forward (through GoDaddy) to the one hosting account.
I want to display a message to users who come to the site from mysite2.com url.
I was thinking I could use PHP HTTP_REFERER to do so.
Is th开发者_StackOverflow社区ere a way to do this?
if(preg_match('@mysite2\.com@i', $_SERVER['HTTP_REFERER'])) {
print 'Special message!';
}
Actually, HTTP_REFERER
will tell you where the user was PREVIOUS to the current page. I think you are looking to use $_SERVER['HTTP_HOST']
instead. This will always yield the domain the user is currently on... mysite1.com
or mysite2.com
精彩评论