Managing redirects within a WordPress site

I often find myself weighing up the pros and cons of using a WordPress plugin or the .htaccess file to manage redirects.

There are a number of factors to weigh up when deciding how best to manage a site’s redirects when using WordPress. I will discuss a few of those factors.

Performance

Redirects that are placed in the .htaccess file are processed by Apache before the WordPress application sees the request. This will result in less load on the application.

When using a plugin to manage your redirects, it is an expensive operation to load up WordPress only for it to deliver a 301 response and start the request cycle all over again.

Maintenance

Only experienced web developers should be editing the .htaccess file as a simple syntax error will disable the entire site.

A WordPress plugin will provide an easy to use interface for managing redirects allowing the website owner to set up, configure or delete their site’s redirects.

Complexity

I am quite often handed a spreadsheet of redirects by an SEO manager and asked to add them to a site. I often take it upon myself to see how many of those rules can be sensible reduced into a single redirect rule, for example a paged list can easily be reduced into a single rule by using a regular expression to capture the page number. This kind of complexity is really only scratching the surface of what can be done with rewrite rules.

Version Control

As with any good piece of software, a website should always use version control. I am a strong believer in this and always promote best practise with everything I do. By placing your redirect rules into the .htaccess file you are getting all the benefits of version control – you can see who added what and when. This benefit speaks for itself.

Conclusion

This choice does not have to come down to one or the other and making a justification for using both is very reasonable in my opinion. I think what is important is deciding which redirects should go where.

For large number of redirects, typically caused by a site migration – these are a perfect candidate for the .htaccess file. It is very unlikely that someone would need to edit these once they are setup and usually provides a good opportunity to condense many rules into a single rule.

If the website owner wants to setup an adhoc promotion and perhaps promote it with a short URL, using a plugin for this is absolutely fine. The load on the application might be a small concern but this can easily be mitigated with a well configured front end proxy.

From the blog

Contact me