Jump to content

if redirected from another url ?


Kane250

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/174468-if-redirected-from-another-url/
Share on other sites

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'];

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.

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.