Search code examples
phpjavascripthttp-redirectsearch-engine

Javascript redirect vs PHP redirect, which would search engines see as regular content


I'm guessing that using PHP's header("location: here.html") would be much better javascript's window.location("here.html") as far as search engine visibility goes. I would assume that the server redirect would show google the correct content and the javascript redirect would be read as a page with the javascript redirect code in it.

Reason being is I have a client that wants me to take their current website and import it into a CMS system (I'm using e107) and I don't want their old pages to lose their current page rank. I was thinking of putting redirects on the old pages to the new pages in the CMS system.


Solution

  • The only way to forward on search engine rank is with an HTTP 301 (permanent) redirect.

    Using PHP's header('Location') will give a 302 unless you specify the code like this:

    header('Location: http://....', true, 301);
    

    It might be easier to use .htaccess, like this:

    RewriteRule ^old.php /new.php [R=301]