How to Redirect a WordPress Page: Add Redirects Manually or Use a Redirect Plugin

How to Redirect a WordPress Page: Add Redirects Manually or Use a Redirect Plugin

Since there is so much content circulating nowadays, the threshold for mistakes is becoming lower and lower. A site, regardless of content, is expected to be engaging, easy to look at, fast, and fully functional. However, there’s a lot to consider when we say “fully functional”.

For example, you can’t afford to have visual design flaws like overlapping content. Another significant issue is dead links to pages and posts. Just imagine it from the frontend perspective – you’re surfing, going through the pages, and then, suddenly, you hit the dreaded 404 error (page not found).

Those are the instances we’ll be focusing on here – what can cause them and, more importantly, how you can minimize the chances of them happening.

How to Combat Dead Links

ChainsYou get dead links when the original URL of a page or post is changed. Such links represent a big enough problem for internal links that connect your pages but are a much bigger issue outside your site. The original URL of a page is the one that is used in search engines, most prominently Google.

So, when an URL is changed, the search engine won’t recognize the change and link your potential visitor to that 404 dead page. Thus, not only will you lose that visitor and many more that follow the same link, but your SEO rating will start to slip, ranking your pages lower, diminishing your traffic overall.

The way to resolve these kinds of issues is with 301 redirects. A 301 redirect stands for the automated process to get both search engines and people to the correct address. While there are other types of redirects, these are crucial for WordPress sites.

Therefore, the essential thing 301 redirects do is let search engines know the URL change is permanent, essentially just exchanging one URL for another – from the frontend, nothing is changed on the surface. Still, underneath, you know you’ll get to keep everything your page(s) have accumulated over time (rating, traffic, etc.).

When and How to Use 301 Redirects

We’ve mentioned it a few times so far, so you can probably guess that using 301 redirects is closely tied to changes made to the URL of a page or a post, but we can break that down to a couple of specific situations. You could be looking to merge multiple posts into one greater than the sum of its parts. So, you’ll need to redirect visitors from each of the individual posts to the combined one – a 301 redirect would have to be used three times for every single original post.

Furthermore, you could change your domain; let’s say you’re switching your hosting providers, and with it comes a new domain. Now this will not be a case of a couple of situations. Instead, you’ll want to switch your entire old WordPress install to the new one, basically redirecting every URL you have to the new ones.

Naturally, there are many other reasons to list, like changing the URL name for SEO purposes, internal errors, various forms of site testing, etc., each of which can and should be handled by 301 redirects. As is often the case with WordPress, there are two ways of doing things – manually and through a plugin.

Using code is when working with websites is always a viable method and, as such, is worth mentioning and explaining. However, with the need for a web presence constantly growing and encompassing an ever-larger number of people, methods used to get your content out there have become much more user-oriented, i.e., designed with beginners and non-programmers in mind.

Moreover, there’s a plugin for virtually everything, and 301 redirects are no different. We’ll go over how you can manually create redirects through modifying the .htaccess file and how to do so using a plugin such as WP 301 Redirects.

WP 301 Redirects featuresAdd Redirects Manually

Before doing anything, remember to back up your .htaccess file. That file is a core part of WordPress and is essential for everything to work. In case something goes wrong, it’s crucial to have the original file fall back on. We suggest keeping a duplicate on a separate drive just for security.

As you would expect, to modify the .htaccess file, you first need to locate it. Unlike similar system files in Windows that are in hidden folders, this is relatively easy to identify – it’s in the root folder of your WordPress site, along with everything else (like wp-admin or wp-content).

.htaccess fileOnce located, you’ll need to open it with Notepad, after which you’re presented with a page full of code you’ll need to navigate through. Essentially, you’ll be looking at a list of various rules that govern the ins and outs of your site. To implement the desired redirects, you’ll have to input additional code to everything already present – don’t change anything that’s already there.

Furthermore, there are two ways to go about this – redirecting individual posts and pages or redirect the entire site to a new domain. To redirect a post or page, add the following code:

Redirect 301 /old-URL https://yourdomain.com/new-url

The old URL requires only the page/post designation after the domain name, while you have to enter the new domain wholly, domain included. An example to redirect “www.test-site.com/redirecting” to “www.test-site.com/how-to-redirect” would like this:

Redirect 301 /redirecting https://test-site.com/how-to-redirect

While this seems simple enough, remember that this is a one-off, which means you’ll need to repeat it for every post or page you wish to redirect.

On the other hand, you could redirect your entire to a new domain. You can do this by adding the following code:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old domain.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]

Here, the original domain name is replaced by the new domain name, but the structure of your links will remain the same, so “olddomain.com/news” redirects to “newdomain.com/news”. Take note that there are other ways to redirect an entire domain, representing just one of them.

However, keep in mind that these are basic code examples and are glorified placeholders. They can be copied/pasted into your file in rare instances and will work right away, but more often, you’ll need to adjust them to fit your site precisely.

Add Redirects Using WP 301 Redirects

WP 301 RedirectsWith WP 301 Redirects, everything revolves around rules you set up to redirect pages. Because of the specifics of coding, plugins have been developed that make these actions much more accessible to a broader audience.

One of the most common reasons to use plugins is to create a more straightforward effort, ideally without using any code – WP 301 Redirects is no different in this regard. However, there’s a one even better thing, and we’ll be taking a look at that first.

Automated Redirects

Now, you’re probably thinking that you’ll have to jump through at least some hoops to get everything working, but you won’t. The best way to get work done isn’t to make it easy, but instead, to not have to do it at all. Quite possibly, the defining feature of WP 301 Redirects is the automated redirects. As soon as the plugin is installed, by default, the automatic redirects are activated and start their work.

Automated redirectsMoreover, the automated redirects look for existing slugs that are similar to the ones manually entered, meaning, most of the time, they’re redirecting visitors who have entered the URL with a typo but don’t dismiss how many of these visitors are out there.

Furthermore, you can choose when the auto-redirect takes place. By default, it’s on posts and pages, and you should keep it that way. Outside of auto redirects, you can set up rules about redirecting to a specific page when a visitor encounters the 404 error. You also have the option of keeping the default WordPress page, redirecting to any of the currently published pages, or create a brand-new page that will do the job.

404 Error redirectNow, if you’re doing some testing and know that some pages will be offline, you can easily disable the redirect rules. If you need to always stay on top of things, be sure to enable email reporting to inform you any time someone uses the redirect. Such notification is helpful to pinpoint any problematic pages or posts that are frequently visited – unsuccessfully.

You can do this for the whole site or just for logged-in users (since they’re the ones that need to have access to all the features). Another thing to consider is how the rules you’ve made will function after you potentially remove the plugin. Unless stated otherwise, the redirect rules will remain in place on your site even after you delete the plugin.

Email reportingSuch rules ensure continuity if you ever use the plugin again in the future or work out your redirects some other way. If you want, you can disable this option in the settings so that everything reverts to its default states after the deletion of the plugin.

Advanced optionsFinally, you can import your sets of rules if you already have them when you start using the plugin, and you can export the ones you’ve made if you’re looking to use them elsewhere. You’ll find this helpful if you manage multiple sites and have already made a set of rules that work for you.

ToolsCreating Rules

Moving away from automated redirects, let’s go over how you create custom redirects within WP 301 Redirects and why it’s more user-friendly than using code. The process essentially consists of filling out a short form that, once completed, functions as a rule for the set parameters. There’s even a handy cheat sheet that pops up with the rule window you can consult while creating your rules.

Add new redirect rule optionIn our example, we’ve decided to redirect the original sample page to a new sample page; just like creating manual redirects, the two main things are the original location and the new location. Like what we’ve had there, the actual URL requires just the page, while the redirect URL needs the entire line to function.

In addition, parameters should generally be ignored as well as rule priority. Both are redundant in the process of creating “regular” redirects. While 301 (permanent) redirects are the main feature here, you can also use other redirect types based on your situation and needs.

Finally, if you’re using multiple redirects on your site, it would be wise to add tags to them for easier sorting and handling – these things tend to pile up before you know it.

Logs

Another thing, alongside auto redirects you don’t get by manually adding rules, is the analytical logs. You can take a deep dive into redirection and 404 logs, respectively. Both graphs offer insight into what redirects were used, how many times, IP locations, devices, traffic types, etc.

LogsMoreover, you’ll find both logs helpful when trying to obtain additional information regarding your URLs and redirects. For example, if you’re trying to single out a malicious IP, looking to customize your site for the average visitor like reconfiguring the display for smaller screens (because data shows 2/3 of your users are on mobile); or pondering adding a new language – these will be your guidelines.

Through the 404 logs, you can even adjust the redirect rules straight from the table without the need to go back to a tab and initiate the rules window. This adjustment makes you work faster and minimizes potentially forgetting to amend rules once you leave the log.

Summary

The main reason you’d use a plugin instead of code is a lack of knowledge – there’s only a limited percentage of overall users who can get the job done manually.

Plugins like WP 301 Redirects solve the knowledge problem boiling down the entire process to filling out blank fields and add so much more to through advanced features and analytics that they’ve become popular even among more accomplished users. Here, we’ve presented you with both solutions and leave it to you to choose yours.

Editorial Staff
mail@85ideas.com

Editorial Staff at 85ideas is a team of WordPress experts led by Brian Harris. Here to share amazing tuts, guides and collections.

No Comments

Post A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.