Efficiently generate sitemaps and check links, markup & css, maintain error free, search engine friendly, websites.

Download 5.0.21

Updated Mar 11, 2012

Preventing Broken Links

Posted: Jan 27, 2011 in Announcements

The best way to fix broken links is to avoid breaking them. Ideally, each document should be known by one URI forever. When that isn't possible, you can avoid breaking links and preserve search engine ranking using HTTP redirects.

When I redesigned illumit.com, I decided that a lot of resources should be renamed. I used weblight to quickly generate apache RewriteRules that redirect resources I had moved and test that I hadn't broken any links.

Adding RewriteRules

I knew that quite a few documents had moved so I exported the urls in use at illumit.com from WebLight's Explore window. With some global substitutions I had the first part of the RewriteRules like these:

RewriteRule ^Privacy/
RewriteRule ^Products/weblight/
RewriteRule ^Products/weblight/Download.html

All that I had to do was decide where the URIs that changed should be redirected to, and which flags to use. I added [R=301] to most rules since the documents had moved permanently.

After editing, the rules that I added to the .htaccess file on my development server looked like this:

RewriteRule ^Privacy/ about.html#privacy [NE,NC,R=301]
RewriteRule ^Products/weblight/ weblight/ [NC,R=301]
RewriteRule ^Products/weblight/Download.html weblight/ [NC,R=301]

Testing Redirects

WebLight validates and checks links in xml sitemaps. This makes testing sites that you reorganize easy:

  1. Export a sitemap from the original site
  2. Change the urls in the sitemap to point at your development server
  3. Add the sitemap file as a starting url in the weblight project that you use to test the site that you're developing on
  4. Check the project

I kept another copy of the original sitemap so that I could test the final site when the upgrade was complete.

This process is pretty painless and allows you to correct URI problems without breaking links or loosing search engine ranking.