How to serve a different header and footer based on incoming domain?

Permalink 1 user found helpful
Hi There,

We've launched a site with identical content being served on two top level domains to two countries.

The site hasn't been setup to 'trick" Google in any way, it's been setup like this because it reflects the company - one business selling the same products and services in 2 markets.

We went with top level domains because this is what Google seems to recommend - the idea being that Google will serve the correct top level domain depending on which country people search from.

However, because the server is physically located on one country, Google is ranking this country much higher and is serving this country's top level domain to all markets.

To counteract this, the advice we've received states we need to have country specific content on each page - probably the header and the footer.

Does anyone know what would be the easiest way to accomplish this in c5 as we want to avoid two versions of each page?

Any help would be much appreciated.

Cheers

Ben

 
mkly replied on at Permalink Best Answer Reply
mkly
Hey Ben,
Are you asking how to use a different header and footer based on the domain name?

If so you could do something like this.
Create a file
elements/header_switcher.php

With this
$domain = $_SERVER['HTTP_HOST'];
if (strpos($domain, 'example.com') !== false) {
  $this->inc('elements/header1.php');
} else {
  $this->inc('elements/header2.php');
}

And then have a
elements/header1.php

and
elements/header2.php

with the different headers.
Do the same with a
elements/footer_switcher.php


Hope that makes sense,
Mike
cmscss replied on at Permalink Reply
I don't know much php, but actually that does kinda make sense.

Cheers

Ben
cmscss replied on at Permalink Reply
Worked perfectly mate - thanks heaps!

Cheers

Ben