Troubleshooting & How-Tos 📡 🔍 Web Development

When Not To Use A Redirect

Don’t use a redirect when changing a setting on your web server would do the job better.

HTTP redirects have a lot of uses: keeping old links viable when pages move, sending downloads to the right mirror, correcting obvious typos, moving plain HTTP requests to HTTPS, providing aliases that you expect people to guess, URL shorteners…The list goes on. But there are times when they aren’t the best approach. For instance:

  • Redirecting the home page to index.cfm, index.asp, etc. instead of just changing the default in the site config so that www.example.com loads that page.
  • Redirecting failed requests to an error page instead of just setting the error template.
  • Redirecting to a separate mobile page instead of putting in the effort to make a page that adapts. Or worse, redirecting to the mobile site’s home page. Fortunately this is less common than it used to be!

These are all situations where the page should live at the original location, but the website sends you somewhere else instead. And the drawbacks of a redirect outweigh the convenience.

  • There’s always a slowdown. Even on a faster network, since each redirect starts a new connection, it never gets the chance to ramp up to full speed while you’re bouncing around from one intermediary to the next.
  • Redirecting to a mobile page makes links less reliable when shared or bookmarked.
  • Redirecting to an error page prevents someone from fixing a typo, forcing them to start all over again. And it can mislead link checkers and search spiders into thinking the page is still up, just at a new location.
  • Redirecting the home page makes it harder to change your tech stack without breaking bookmarks, history and incoming links.

Consider this scenario:

  1. Build site in PHP.
  2. Make home page redirect to http://www.example.com/index.php.
  3. Get lots of people to bookmark and link to http://www.example.com/index.php.
  4. Rebuild site in ColdFusion.
  5. Redirect home page to http://www.example.com/index.cfm.
  6. Watch all those old links and bookmarks break. Gee, I hope you have a good 404 page!
  7. Of course, you can fix it by adding another redirect from index.php to index.cfm…

Better to just use the right tool the first time and let the home page live at the top of the site.