2

I have a portfolio website that I have created with wordpress theme X, that is featured on two websites that showcase examples made with theme X.

I am in the process of making a new portfolio website, based on my own wordpress theme, but I would like to keep the old website on a subdomain for the visitors that are refered from the showcase websites.

Is it possible to only redirect visitors that come from those specific sites to the subdomain (old.portfoliowebsite.com)?

Is there any way to do this (other than asking the showcase websites to change the link)?

1

One way that comes to my mind would involve using PHP:

$_SERVER['HTTP_REFERER']

You could check for the refering URL and implement a redirect accordingly:

if($_SERVER['HTTP_REFERER']=="http://www.example.com/") {
    my_redirection_fuction();
}

This is however a rather unreliable method since people can hide the refering url through browser privacy setting.

3
  • If I understand correctly: users that are browsing in private or incognito mode will not be redirected. Or are there other privacy settings that will hide the refering url? – AnaLog May 7 '15 at 10:22
  • 1
    @AnaLog The HTTP referer is still set by the browser in "incognito" mode. TBH the user needs to go out of their way to block the referer (I don't think you can do this in Chrome "out of the box"?). The "problem" with this approach is that the referer can be faked (or not sent) by the user/browser, so you wouldn't use this method to protect content. However, in this (none critical) case I would have thought it's perfectly OK. – MrWhite May 7 '15 at 10:52
  • Yes, that is what i meant. There are probably other settings and factors that can have an effect on the reliability of the referer url – in my experience about 60%–80% are 'under cover' or 'not reliable' but I may be mistaken with this. It's a nice piece of extra information you can use but you shouldn't rely on it… – tillinberlin May 7 '15 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.