Mjc
Mjc

Reputation: 11

PHP redirect based on multiple (more than 5) referring domains

Currently we have 25+ domains forwarding to one single www.mydomain.com. What I need to do using PHP is forward traffic once again to www.mydomain.com/#.html based on the referring domain. so...

www.mydomain1.com -> www.mydomain.com -> www.mydomain.com/1

I've been able to accomplish this for 2 using an If/ElseIf/Else statement, but to take it further, I believe I will need to use a Switch/Case routine, but I'm not sure of the best way to do it.

Upvotes: 1

Views: 615

Answers (1)

Kevin Nelson
Kevin Nelson

Reputation: 7673

$referrers = array(
  "domain.com" => "somepage.html",
  "domain2.com" => "somepage2.html"
);

$referrer = //get domain coming from

if( !empty( $referrers[$referrer] ) ) {
    // redirect to $referrers[$referrer];
}

Upvotes: 5

Related Questions