Kane250 Posted September 16, 2009 Share Posted September 16, 2009 Hi, I have a website set up with two domain names, 1 main domain for the site, and 1 that forwards you to the main domain name. I'm trying to set a variable where I can do one thing if you came to the normal url or do another if you were forwarded from the redirecting url. To make it a step harder, I don't want to do the simple solution and pass a GET variable from the redirect url to the main page. I tried using echo $_SERVER['HTTP_REFERER']; But this obviously doesn't work with domain forwarding, as I am getting an undefined variable error. Anyone know of other methods? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/174468-if-redirected-from-another-url/ Share on other sites More sharing options...
JonnoTheDev Posted September 16, 2009 Share Posted September 16, 2009 But this obviously doesn't work with domain forwarding Have you use a proper 301 redirect on the domain? Does your server have php > 4.3 to obtain headers? Should work fine if all of the above are true. $_SERVER['HTTP_REFERER']; Quote Link to comment https://forums.phpfreaks.com/topic/174468-if-redirected-from-another-url/#findComment-919553 Share on other sites More sharing options...
Kane250 Posted September 16, 2009 Author Share Posted September 16, 2009 Well I'm trying to find out from my IT dept here if it is being done a different way, but I do believe that it is a standard 301 redirect. The urls come in from other pages, and even if I click back to the homepage from an internal page on the site. The only undefined one is when I get redirected from the other domain. Quote Link to comment https://forums.phpfreaks.com/topic/174468-if-redirected-from-another-url/#findComment-919640 Share on other sites More sharing options...
Kane250 Posted September 16, 2009 Author Share Posted September 16, 2009 Yes were doing a standard 301 redirect, but this still doesn't work... Quote Link to comment https://forums.phpfreaks.com/topic/174468-if-redirected-from-another-url/#findComment-919653 Share on other sites More sharing options...
JonnoTheDev Posted September 17, 2009 Share Posted September 17, 2009 The 301 url will not send a referrer header hence you cant pick this up. I would use a 301 to a landing page on the target domain where you can record that a redirect has occurred. Once logged use another 301 to the base url i.e. www.abc.com -> 301 redirect to www.xyz.com/landing.php www.xyz.com/landing.php -> record referral -> 301 redirect to www.xyz.com www.xyz.com Quote Link to comment https://forums.phpfreaks.com/topic/174468-if-redirected-from-another-url/#findComment-919962 Share on other sites More sharing options...
Kane250 Posted September 21, 2009 Author Share Posted September 21, 2009 Thanks. Since it seemed like the only way to do this was to make a landing page, I actually ended up going for the easier route and just passing a variable through the forwarded URL. It's not as clean, but I think it's as simple as I can make it work at this point. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/174468-if-redirected-from-another-url/#findComment-922443 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.