开发者

Can I use PHP HTTP_REFERER to display a special message?

开发者 https://www.devze.com 2023-03-05 00:49 出处:网络
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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号