Redirecting old pages after a website rebuild
Why do old links break after a rebuild?
Because the addresses changed and the rest of the web didn't hear about it. MDN makes the point well. Even if you update your own links, you have no control over the URLs used by external resources1. Other sites, bookmarks and old emails still point at the old address.
Left alone, those visitors land on an error page, and you lose the people those links used to bring.
What do I do first?
Make a list of every old address. Google's guide for moving a site calls the next stage a mapping of old to new URLs2. A URL is a web address, so the mapping is a two-column list: old address, new address.
Where do the old addresses come from? Google suggests checking your server logs for URLs that were visited at least once recently2. It also says to pick a time period that suits your site, and to allow for seasonal changes in traffic2. Include pictures, videos and files too, since Google says those addresses need moving the same way as everything else2.
Don't have access to server logs? Ask your host, and read their help pages for how logs work on your plan.
How do I decide where each old page goes?
Send each one to the page that now covers the same thing. Google says to decide where each old address should redirect to, and that how you store the mapping depends on your servers and the site move2. It could be a database or a set of rewriting rules2.
If three old pages were merged into one new page, all three can go to it. Google confirms that if you consolidated content from multiple pages into one, you can redirect the older addresses to that new page2.
Can I just send everything to the home page?
It's tempting, and it's a poor trade. Google says not to redirect many old URLs to one irrelevant destination, such as the new site's home page. It can confuse users and might be treated as a soft 404 error2.
Think of the visitor who clicked a link to one specific page. They want that page, or its closest match, and not your home page.
What kind of redirect should I use?
A permanent one. Google recommends server-side permanent redirects from the old addresses to the new ones, as laid out in your mapping2. It says to use HTTP permanent redirects, such as 301 and 308, if possible2. The page on redirect codes explains the difference.
Server-side means the server itself sends the redirect. Google suggests asking your server administrator or hosting company what kinds you can set up. It might be rules in an .htaccess file on Apache, or redirect functions in your content management system2. If none of those are possible, Google says you can fall back to client-side redirects as a last resort2.
Should I fix my own links too?
Yes. Google lists this as a job to do: change the internal links on the new site from the old URLs to the new ones. The mapping you built helps find them2.
MDN gives the reason. A redirect has a significant performance cost, and if you can avoid it by correcting internal links, you should fix those links instead1. It says to try to avoid having internal redirects1.
How do I switch it on and check it?
Once the mapping is right and the new site is ready, you turn the redirects on. Depending on your set-up, Google says that might mean pushing an update to your server configuration files or updating your content management system2.
Then test. Google's advice is simply: test the redirects. It mentions command line tools or scripts for testing large numbers of addresses2. The page on checking a redirect shows a simple way.
Google also warns that people often redirect to the wrong, non-existent addresses on the new site, so check the redirects from the old site to the new one2.
How long do I keep the redirects?
Longer than you'd think. Google says to keep them as long as possible, generally at least 1 year. That gives search engines time to transfer signals and reassign links on other sites2.
For visitors, Google says to consider keeping redirects indefinitely. It adds that redirects are slow for users, so update your own links and any high-volume links elsewhere to point at the new addresses2.
Don't expect instant results in search. Google says a small to medium-sized website can take a few weeks for most pages to move2.
Further reading and sources
- Redirections in HTTP, MDN Web Docs (Mozilla)
- Site moves with URL changes, Google Search Central