Web Hosting

1 More Plugin Bites the Dust: Redirection

Back here I wrote about the benefits of using as few plugins as possible on your site.

As is typically me, this has turned into a bit of a crusade (removing plugins from my site, that is).

Here, again, are the reasons for my crusade:

Plugins can slow down site load times, they may fall behind WordPress developments (potentially causing problems after upgrades) and they create more to go wrong.

Removing the Redirection Plugin and Doing Redirects Manually

There are often better ways of achieving what your plugins are achieveing, so here’s what I did with Redirection.

Before we go any further let me make it absolutely clear: Redirection did a great job for me.

I experienced absolutely no problems with the plugin itself and, if you’re not ready to play around with your .htaccess file, this plugin will handle redirects for you without any problems.

But remember my crusade: I’m progressively removing as many plugins from my site as I can, replacing them with other ways of achieving the functionality they provide.

My experience and use of Redirection

Redirection does a number of things:

  • It enables you to set up manual re-directs where you change a post permalink
  • It automatically creates a 301 redirect if a permalink (post URL) on your site changes
  • It logs 404 errors
  • It provides statistics and reports on anything to do with redirects and 404 errors.

It’s a powerful plugin and I had it installed for about 18 months in total.

During that time I set up 4 manual redirects where article permalinks had changed. I set these up when I originally installed Redirection. In fact the reason for installing it was because I changed the permalinks on those 4 articles to make them more SEO-effective.

No auto redirects were set up by the plugin during that time because no permalinks on any other articles were changed.

I want as few 301 redirects as possible on my site. So I always give a lot of thought to permalinks when I publish new articles in order to avoid any temptation to change them later.

With that low level of use, I figured if I could learn how to set up 301 redirects manually in my .htaccess file I could do away with Redirection, saving myself another plugin.

What I did

I searched online for tutorials on how to set up 301 redirects.

301 type redirects, by the way, are permanent redirects. These are better for SEO purposes (you don’t lose incoming links) and they also update the visitor’s browser if they already have the page bookmarked under the old URL.

Most of the information I found focused on redirecting existing pages to another URL. In other words – there’s an actual page at link (a) and you add the redirect script to that page (or create a page in a folder and add a PHP redirect call) to send visitors to page (b).

Visitors are being redirected from one page to another.

But when you change a permalink in WordPress there’s a big difference:

You’re not redirecting visitors from one page to another. You’re asking the server to display the same page which now has a different file name from the one the searcher typed in.

You achieve this via the .htaccess file.

As long as you’re running WordPress on a Linux/Apache server you will have a .htaccess file in your blog’s root directory. If, for any reason, you don’t then you can add one.

In that .htaccess file you can type the following command to re-direct visitors to the new permalink:

redirect 301 /old-post-slug http://www.example.com/new-post-slug

Take careful note of the spacing.

Notice, also, that you don’t include the entire URL for the old post. You only need to include the /old-post-slug (if your blog is installed under the root domain name) or /directory/old-post-slug if your blog is installed in a directory under your domain.

But the new URL does need to include the full address, even if it’s on the same site.

So, using that format, I set up redirects in my .htaccess file for the 4 articles I referred to earlier and, hey presto, another one bit the dust. (Plugin, that is).

This will work for most WordPress users because you’re likely to be hosting your site on a Linux/Apache server. If you’re on a Windows server this won’t work for you because Windows doesn’t support the .htaccess file.

But most importantly: take a copy of your .htaccess file before you make any changes to it. It’s a powerful file and screwing it up will likely make your blog disappear into the ether.

If the unthinkable does happen, you can use FTP to restore the back up copy of your .htaccess and you’ll be back in business in no time.

What would be great to know is what you’ve done to remove plugins. Leave a comment telling us what plugins you’ve removed and how you replaced the functionality they provided.

Web Hosting

Comments on this entry are closed.

  • Brad Harmon 4 December, 2009, 9:59 am

    Martin,

    Seems like a lot of bloggers are trimming back lately. I’m lucky that my host provider provides a nice redirect interface so I don’t have to mess with the file directly. Who knows where I’d be redirecting people if I did. 😉
    .-= Brad Harmon´s last blog ..How I Make Money From This Site (and You) =-.

    • Martin 4 December, 2009, 9:39 pm

      Brad, hi,

      Great that your hosting provider provides a good interface – it’s just possible, though, that re-directs entered through the interface won’t work on WordPress.

      This blog’s on Hostgator and doing the redirects through the cPanel redirections module did not work. When I queried it with Hostgator their response was that WordPress itself was processing the redirect (in my case to my 404 page, because I was entering the old URL) before the redirects added via the interface could do their stuff.

      That’s why I ended up having to do them manually.

      I was getting super frustrated at one point but, actually, the re-direct code is so simple that I ended up being happier doing it that way.

      Cheers,

      Martin.

      • Brad Harmon 4 December, 2009, 9:54 pm

        I really wish I hadn’t read your response. You know they say ignorance is bliss. I use Hostgator too, so I guess my redirects aren’t working after all. 🙁

        Guess I’ll be bookmarking this post for when I feel brave enough to tackle this. Thanks for the info though because I would have went on thinking my redirects were working.
        .-= Brad Harmon´s last blog ..How I Make Money From This Site (and You) =-.

        • Martin 4 December, 2009, 11:04 pm

          Try out your re-directs to see if they’re working – i.e. type in your old url and see where you end up.

          If it’s not working give me the full old url and the full new url and I’ll create the code for you, paste it into a text file and explain how to add it to your .htaccess.

          You don’t really want your readers ending up on a 404 🙂

          Cheers,

          Martin.

          • Brad Harmon 8 December, 2009, 9:30 am

            Hey Martin. Thank you for the offer. I think there was only one redirect, but it’s not something anyone should be looking for now that it is out of the cached versions of my pages. I am grateful for this information though because I didn’t know what I was doing was not working.
            .-= Brad Harmon´s last blog ..Guess Who’s a Member of the Famous Bloggers Club =-.

            • Martin 8 December, 2009, 1:45 pm

              You’re welcome – cheers!

              Martin.

  • corrie 4 December, 2009, 10:51 am

    Martin,

    You are overwhelming me. ;-). I may have to stop reading you until I can “catch up.” I know this is good information, but TMI for me right now.

    Just, kidding. I wouldn’t leave you. In fact, I’m directing people to you. Noticed a big bump in your traffic? (Hahahaha)
    .-= corrie´s last blog ..Not Just Jonathan =-.

    • Martin 4 December, 2009, 9:34 pm

      OKAAAY – I wondered where those extra 3,000 came from..!! 🙂

      But fear not – these articles will be here for a long, long time – I have no plans to purge anything!

      Cheers,

      Martin.

      • CorrieHowe 4 December, 2009, 11:59 pm

        If you got a bump of of 3,000 then send them to me…cause they didn’t come from my site. :-O