How to handle permanent redirects in wordpress

There are multiple options available to handle redirects in wordpress. A redirect is a way to tell the users and search engines that a page have moved to a new location. The move can be temporary or permanent. For permanent move “HTTP 301” header is used by web servers. Here is a example using HTTP live headers Firefox plugin:

http-live-header-301-redirect

In this example a url http://infoheap.com/category/hosting/ is being redirected to http://infoheap.com/tag/hosting/. This is the response which tells browsers or search engine crawlers/bots that the page have moved permanently:

HTTP/1.1 301 Moved Permanently
Location: http://infoheap.com/tag/hosting/

There are multiple ways to handle permanent redirects in wordpress:

  1. When a post or page is renamed, wordpress automatically generate the redirect header as it stores old urls in revisions. So you dont have to do anything. But if you clean the old revisions data regularly (I use wp-optimize to clear old revisions regularly) for performance reasons, this may not work.
  2. Using some redirection plugin. I have tried Redirection plugin and this seems to be one of the best plugin for handling redirection. You specify source and destination url and it takes care of redirection for you. It also generates reports on how many redirects happened, etc. In addition it provides 404 reports also for “page not found” errors.
    wordpress-redirection-plugin-descriptionwordpress-redirection-plugin-settingsI would strongly recommend this plug to handle redirects.
  3. One more option is to use apache RedirectRule in apache configuration as show.
    RewriteEngine On
    RewriteRule ^/category/technology/hosting/   http://infoheap.com/tag/hosting/   [L,R=301]

    This uses apache mod_rewrite extension. Now why would you use apache configuration option when more user friendly options are available? Using apache is usually faster as it happens much before php scripts are loaded and there is no database query and update. So in cases where there are many hits on some specific urls, you may want to consider this option.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments