how to setup 301 redirects in wordpress

How To Setup 301 Redirects In WordPress

Table of contents

    Estimated reading time: 14 minutes

    In this article, I have recorded a video to show you how to set up 301 redirects in WordPress using two of my favourite WordPress plugins: Yoast SEO Premium and Redirection.

    There will be times when you need to redirect visitors to a different page of your WordPress site when they visit certain posts or pages. You may need to do this when you have renamed a single page and its URL, you have deleted a page or you want a different page to rank. Not only does this improve usability for your visitors, but it helps to preserve link juice too.

    Setting up simple 301 redirects can be done by editing your htaccess file, or an easier way to create a redirect is to use a 301 redirect plugin.

    In this video, I will take you through the WordPress plugins that I recommend for web tools redirection – you can watch the full video below and also see the bottom of this article for a full-text transcript of the recording.

    Video Transcript

    Hi guys, this is Michael from Improve Position, and in this video, I’m just gonna very briefly take you through the easy steps of setting up a 301 redirect in WordPress.

    So what is a 301 redirect? If you’re not sure, which I’m sure most of you probably are, hence why you’re watching this video, but if you’re not sure what a 301 redirect is, it’s basically redirecting a user from one page to another. And this is used when a page has either been changed or been moved or been deleted.

    So, for example, if we had a contact page, a URL such as improveposition.co.uk/contact-us, and we change that URL to improveposition.co.uk/contact, that means if someone visits the old URL, the /contact-us, they will land on a ‘Not Found’ page, which generates a 404 error.

    Now, 404 errors aren’t good in the fact that, one, from a usability perspective, if a visitor lands on that, it just doesn’t look very good for you and your brand, because it comes across that obviously your website isn’t maintained and content is missing, and it just doesn’t give a very good impression.

    And second to that is Google, or any search engine really, but I’m using Google obviously ’cause they dominate the search market. From an SEO perspective, it’s not great. It gives a signal to search engines that your website is also not being maintained, not being looked after. And obviously, if it’s a website that’s not really being looked after a lot, they’re not really…they’re not encouraged to promote it.

    So moving on, obviously, to setup 301 redirects, there’s loads of different ways of doing it. The main way of doing it is manually, via a htaccess file, and that’s okay to do if you’re a developer and you’ve got that experience. Most people who are using WordPress, I would imagine, don’t have that experience, so the second option there really is to use a plugin.

    So what I’m gonna do today is I’m gonna just take you through two plugins that I personally use, they’re my favourites for setting up 301 redirects, and I’m just gonna show you how to do that.

    Now, there’s two plugins I recommend, one is Yoast SEO. Now, Yoast SEO comes with, as you can see here, there’s a free version and there’s a premium version. The free version, to be honest, is really good. I use premium on our own company website because I like some of the additional features it’s got, it’s just quite handy, but it’s no better from an SEO perspective.

    They both do what it needs to do, so, for clients, I usually use the free plugin. It’s just that the premium comes with a few extra features like you can add in secondary keywords, and you can use like previews of your open graph data for Facebook and Twitter and that type of thing.

    Now, the free version doesn’t come with a redirect feature, whereas, the premium one does. So if you are using Yoast, and you feel that you want to use a lot of the premium features, then what I would do is I would say if you’re gonna upgrade to the premium or if you already have the premium, use the premium version for your redirects.

    If you don’t have the premium version, so if you’re using the free version of Yoast or if you’re using another SEO plugin, then I strongly recommend this one, which is just simply called Redirection by John Godley.

    So, excellent plugin. I use it all the time for all my clients. I don’t use anything else for redirects unless, as I say, unless they’ve got a premium version of Yoast, but to date, I don’t think I’ve got any clients that actually are using the premium version. So, yeah, I love this. It’s very, very lightweight, it’s really simple, and you can even upload in bulk as well, which I will take you through in a second as well.

    So let’s start with Yoast very briefly. So I’ve got two websites here, that one’s using the Yoast premium plugin and one’s using the Redirection plugin because it’s only using the free version of Yoast.

    So we go into the dashboard here and we come into SEO. If you’re using the premium version, you will see a little menu here that says redirects. So if we click on redirect here, what you’re presented with here is all of the redirects that have been setup. And so we’ve got the type of redirect, as we’ve already mentioned, you’ve got 301s and 302s. You’ll have the old URL and you’ve got the, which is relative as you can see here, and the new URL, same again. So you’ve got the redirects tab at the top, which obviously is very simple. Again, you just select the type, the old URL and the new URL.

    You’ve also got this additional REGEX Redirects, which is a little bit more complex. As you can see, this website’s not used any, but this basically enables you to use, you can use REGEX expressions to basically create different types of redirect structure.

    There’s a link here about REGEX that takes you through to an article on the Yoast website which shows you what REGEX Redirects are and how to structure them. So, that goes well beyond the scope of this video so I won’t take you through that. But if you are interested, obviously, just kinda browse through. And the actual settings of the plugin as well are very simple on Yoast.

    So it’s just choosing your redirect method really. Now, by default, they choose PHP. I advise that as well, so I would stick to that. But you can change it to web server. It’s just basically it depends on your server and how you’ve got it setup as to how your server would handle a redirect, but in most cases, PHP will be fine.

    So, very simply, all we’re gonna do here is, you choose the type of redirect. So here, you’ve got ‘301 Moved Permanently’. And then all you do in here is you can add your URL, the old one and the new one, that’s it, and you click ‘add redirect’.

    Now when you do that, it will take out the domain anyway, and set it to how it needs. So…and it’s really that simple. If you feel you’ve made a mistake, you can come in here, you can either delete here by hovering over or clicking the Edit button and then you can go in and change the URL structure as well.

    It’s really simple, really easy, and whenever you move a page or anything, I would advise doing this.

    Now the great thing about the Yoast SEO premium version, is when you actually change a page…so if you either changed the slug or you delete a page, it will naturally pop up at the top of the browser window up here to say, “Oh, you’ve removed a page or you’ve edited this page. Where would you like to redirect it to?” So it actually enables you to setup the redirects at the time of deleting, which I think is utterly fantastic.

    And that’s something that really none of the other plugins really do to that level, and that’s why I say if you’ve got Yoast and you’re happy to upgrade to premium, yes, do it. I wouldn’t say it’s worth doing just for the redirects, I would say then use Redirection, but if you think that you can make use of all the other features, then great.

    The second one, as I say, is the Redirection. If we go into this website here, which had the Redirection plugin, you just, obviously, do a search in the WordPress library there for… as I say, it’s just called Redirection. It’s by John Godley as well.

    Once it’s installed, once you have activated the plugin, you will find it under Tools, here. So, if you come down to Tools, and you’ll see Redirection here. So we just click that to go into Redirection. Very very similar. Actually, it gives a little bit more information than Yoast, in the fact that what you’ve got here is…you’ve got all these tabs along the top and the redirects.

    Obviously, the type of redirect, again, the URL. So, obviously, the blue one here is the old URL, and then the actual full URL in the black or the grey is the URL it’s gonna go to.

    You’ve got position, which is basically just a list. So, you can see here that it’s just assigning it a different…a number, a numerical value to those redirects as you’re setting them up.

    Hits shows you actually how many times someone’s actually visited that old page and triggered the redirect. That’s really interesting, and it’s really helpful because sometimes, you can see down here, so there’s been a redirect setup here, and actually, it’s only ever been triggered once, and that’s the last access there, says the 11th of January. So that’s okay, ’cause that would have just been the odd sort of link that might have been somewhere, but up here, you can see this Criminal Defence redirect here, that’s been hit 69 times.

    The date is the 20th of February, today, and the last access was the 20th of February 2019, which is today. So, that’s telling me that actual URL there, that’s been…that’s probably in quite a few places. That could be…it could be via a Google search engine or any other search engine, it could be incoming links from other websites or it could even be the website itself.

    So if someone is hitting those links, those old URLs within the navigation that hasn’t been changed, you know, you wouldn’t actually know it as a user because you’re redirect…you’re automatically redirected, you don’t even notice it, but it’s actually…it all takes up server resources.

    That’s a sign actually you might wanna go in, and actually find…actually, look at the website and think, “Okay…” look at the website, look at any external links to that page and see if you can get them updated. Because, although the redirects are important, if you cannot have a redirect trigger then that’s great because it’s… again, it’s using bandwidth and it’s…you know, it decreases load time and stuff like that.

    Just looking at, very briefly across the top, you’ve got groups, basically, the redirection plugin, you’ve got two types, you’ve got, it handles redirections and it handles modified posts. We don’t really…I don’t really use modified posts, and I’m certainly not really gonna cover it in these videos, but basically, you can just categorise them.

    So, if you’ve actually just modified something and you wanna categorise under the modified posts group, then you can do. You can also create your own groups. It’s just a way of you actually categorising your redirects.

    You’ve got a log here, so a log file of all of the redirects and when they’ve been triggered, where they’ve actually been triggered from. So you could see the IP address, the referral agent and stuff like that…and dates they were triggered.

    Any 404s. So any 404 errors that are generated, i.e. redirects that do need to be setup would be in here. So you can see here, okay, on the 20th of February at nearly 7:15 in the morning, someone hit that link there.

    Now what you can do is you can then view that information or you can say, “Okay, well, actually, I wanna setup a redirect for that.” Now, we can see a lot of these here are…they’re scripting URLs or things that we don’t really need to worry about, like text files, JavaScript files. Then down here we’ve got a Criminal Defence and we’ve got here a Cancer Research UK will writing page. Well, I’d wanna check that and then say, “Okay, well, if someone…if I go to that page, if it’s not redirecting, I can come in here and just hit ‘add redirect’.” It’s just a way of actually monitoring the 404 errors, because obviously if your redirects are setup correctly, you shouldn’t have any 404s.

    You can import and export at bulk. Now, that is really handy, something I use all the time, which I’ll go through in a few minutes.

    There’s some options for the plugin, so obviously, you can donate if you want to, which obviously, is quite kind and good to do ’cause it’s actually a free plugin. And there’s things like how long do you wanna keep the 404 logs and the redirect logs and that type of thing, and some other stuff here. I think there’s also a support tab as well, which just shows you the status of the plugin, and obviously where to go if you actually need any help.

    So if we just flip back to the redirects here, you can edit the redirect exactly how you do with the Yoast plugin. Now, what the Redirection plugin requires you to do is the source URL, so the URL that’s your old one, the one that you wanna redirect from, don’t put in your domain, so just put the slash and whatever it is. If it’s a homepage, you just simply put in slash.

    Your target URL, that should be the full page, including whether it be HTTP or HTTPS, or www. So, you assign the group. And then you hit ‘Save’. And it’s the same if you click ‘Add New’ up here as well, it’ll be the same process.

    If we cancel that. You can delete. You can actually disable, which I really like. If you’re not sure, you don’t need something, you can disable, which means, obviously, it stays in the system, it just doesn’t work at the moment. So, you can just re-enable later on.

    And I really like this ‘Check Redirect’. If I click that ‘Check Redirect’, what it does is the plugin will actually just check it for us, and say, “Okay, what was expected? Right, what was expected was the 301, that page to that page, from obviously, this one, and what happened? Yeah, a 301 from that page.” So, that’s great.

    So, it saves you having to actually do a manual check, you can actually just go through and ask the plugin to actually check them. So, really handy.

    Now, if you’re doing a site migration or you’ve got a client where you’ve got…or yourself when you’ve got a lot of redirects, then you probably wanna do them in bulk, because it obviously takes a very long time to setup redirects manually.

    So if you come to Import/Export. You can upload a CSV file, a htaccess or a JSON file. Now I’m gonna show you a CSV, that’s how I do it. What I did was, actually, you can download, in a CSV file, a copy of your existing redirects. So if you download…if you setup a couple of redirects manually yourself, and then download them, you can actually see what the file format is they need. So, I’m just gonna open the file here, because it’s on my desktop, and what you’ll typically find is it will have a source column, in column A, a target column.

    So, obviously, you can see here, it’s just the slash without the domain. The target is the full URL, as it will be. This is actually not using HTTPS. I actually do use HTTPS, so the full URL with everything in it. The code of what it needs to be, and the match, it’s just URL, so just copy all the way down.

    And what I do is if I’ve got a list…usually, when you have a list from a client site or your own site, you’ll have the source URLs that you need to setup the redirects from, you’ll probably have the full URLs, and you don’t need all the…the actual domain. All you’re doing is just to find…copying in all the source URLs, the full URLs, doing a ‘find and replace’ just to remove the domain and replace it with a slash, and then obviously, you can then copy in your main URLs.

    If a lot of them are being redirected to the homepage, for example, you can literally just take that, and then you can copy down, using that kind of…either formulas or drag and drop, and that type of thing. So Excel enables you to do it really quickly.

    And the same with setting up 301s. So I can come in here and just copy those down, same with URL as well, and just change it like that. So once that’s done, obviously, I’ve gotta save that, but you just save the CSV and literally drag and drop it here, or click the ‘Add File’ and browse and do it manually. And that should be it. If it’s in the wrong format, it won’t upload, it will give you an error, and then, obviously, you just follow the instructions to correct it. But as long as you’ve done everything correctly, then it should just upload without a problem.

    Whatever one you try, obviously, have a go, see how you get on, leave some comments, let us know how you found it, or if you’ve actually got any other plugins that you feel are better, yeah, drop a comment, let me know. I will be really interested because obviously, I’ve not tried all the plugins in the world. This is obviously coming from my own experience. So, yeah, let us know how you get on.

    Thanks.

    About the author

    Michael is the founder and managing director of Improve Position with a strong background in both web development and technical SEO. His enthusiasm shines through with his passion to help others understand and succeed in the world of online business marketing.

    Latest posts

    Blog categories

    Blog tags

    Like What You See? Then Why Not Give Us A Share:

    1 Comment

    1. Get Redirects on 28th October 2019 at 10:53 am

      Great video, thanks Michael! Yoast and Redirection is a very good combo for managing redirects in WP.

      If you don’t mind the shameless plug, I’ve built a tool that complements Redirection in cases where you have a lot of redirects to make. It maps old urls to new ones automatically.

      You can check it out for free at https://getredirects.com.

      I’m curious to know what you think.

      Cheers,
      Damian

    Leave a Comment





    Subscribe To Our Newsletter

    to receive FREE marketing hints & tips every month. We never spam and won't pass your details out to any third parties. Unsubscribe at any time. View our privacy policy.