5

So I have 2 URLs that basically link to the main url using a symlink

 maindomain.com  
 englishdomain.com -> symlink to maindomain.com  
 frenchdomain.com - > symlink to maindomain.com/fr 

When someone actually lands on maindomain.com/index.php it will automatically redirect them to the appropriate symlink

The problem I'm having is I think it's affecting my google ranking and I'm not sure why..

this is my redirect code

$url = "http://" . $_SERVER['HTTP_HOST'];

if ( $url == 'http://www.maindomain.com' || $url == 'http://maindomain.com') {
    header('Location: http://www.englishdomain.com/');
}
if ( $url == 'http://www.frenchdomain.com' || $url == 'http://frenchdomain.com') {
    header('Location: http://www.frenchdomain.com/fr');
}

Is it possible that it's affecting my google ranking?

3
  • Using PHP to perform the redirect is marginally slower than using mod_rewrite - is there a reason you are avoiding mod_rewrite?
    – danlefree
    Sep 22, 2010 at 1:57
  • Would using mod_rewrite affect my ranking or google analytics for that matter or is it simply the same result just faster?
    – Serge
    Sep 22, 2010 at 19:57
  • Same result just faster: Google Analytics relies on a Javascript call which won't be triggered if you redirect using mod_rewrite or PHP and your server logs will continue to show the redirects occurring.
    – danlefree
    Sep 22, 2010 at 22:55

2 Answers 2

4

According to http://php.net/manual/en/function.header.php the header('Location: http://www.example.com/') command will send a 302 redirect to the client.

You should use a 301 redirect if you want to 'transfer' the SEO Gold on example1.com to example2.com.

2
  • I believe you have the right answer but I have yet to see any difference. I'm also running a google adwords campaign as well as several ads placed on ad networks and I have yet to see any of those websites in a search result (except of course for the sponsored ad) Even a search for link:englishdomain.com yields no result
    – Serge
    Sep 22, 2010 at 19:58
  • well it's finally starting to show up in results even though webmaster tools doesn't show any information about the links
    – Serge
    Sep 29, 2010 at 22:49
0

In addition to mawtex' answer (which I believe is correct):

// 301 Moved Permanently
header("Location: /foo.php",TRUE,301);

...should do the trick. But please test this thoroughly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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