views:

55

answers:

2

I have undergone a major website overhaul and now have 5,000+ incoming links from search engines and external sites, bookmark services etc that lead to dead pages or 404 errors.

A lot of the pages have corresponding "permalinks" or known replacement hierarchy/URL structure.

I've started to list the main redirects with htaccess or physical files with simply a header location reidrect which is clearly not sustainable!

What would be the best method to list all of the old link addresses and their corresponding new addresses with htaccess, php headers, mysql, sitemap file or is it better to have all broken links and wait for search engines etc to re-index my site?

Are there any implications for having a large number of redirecting files for this temporary period until links are reset?

+4  A: 

why not to have this list in any appropriate format - a database or a flat file, and load it in 404 error handler file? And then just search for the REQUEST_URI, and use header(Location:") to redirect

.htaccess

ErrorDocument 404 /404.php

404.php

<?PHP
if ($newurl=db_lookup($_SERVER['REQUEST_URI'])) {
  header("Location: $newurl", 1, 301);
}
Col. Shrapnel
A: 

Header redirects are definitely not the correct answer. If you want to preserve your SEO, you'll want to do 301 redirects. I don't know what the path structure of your site is, but this should be possible with a clever set of mod_rewrite rules. If nothing else, a slew of

Redirect 301 /old-path /new-path

generated with a script should tide you over.

There are absolutely implications for the redirects. If you're doing a meta refresh with a 0 second timeout, Google will accept that as an appropriate substitute for a real 301 redirect, but others might not. If you're not using that particular method, you're losing all your linkjuice.

Clint Tseng
Do you think this redirect directive send some other header, hehe? :)
Col. Shrapnel
PHP's `header()` function uses a 302 which is handled like a temporary redirect. So you should issue a `header('HTTP/1.1 301 Moved Permanently');` before calling `header('Location: /old-path')` to ensure using a 301 redirect.
kroimon
That's what I meant; I should have been more explicit. +1
Clint Tseng