How to Create Redirects in WordPress

0
301 Redirects in WordPress

Several times, you have to add a redirect to the different pages of your WordPress sites. It is necessary when you change URL structure or alter the post slug of an article. This is because when you change your permalink structure, or if you remove posts or pages, you more likely to generate 404-page errors.

A 404 error means the page you were trying to reach on a website couldn’t be found on the server. It causes because of a website owner has moved a page or resource but did so without redirecting the old URL to the new one. In such cases, you should redirect the visitor to the new location.

[clickToTweet tweet=”Introduction to #WordPress #redirection and how to add them.” quote=”In this guide, I will introduce you to WordPress redirection and how to add them.”]

So let’s start.

What is Redirect?

It is the simplest way for your reader’s browser and tells them that the page they want to visit has been moved. Finding this, their browser will automatically point them to the new page of your choice, where you have redirected the original page.

Redirects are categorized into various types including 301 redirects, 302 redirects, 307 redirects.

301 redirect:

Majority of redirects are 301 redirects. It is an HTTP response code that shows a message that a page has moved permanently.

Adding 301 redirects is the most efficient and Search Engine Friendly method for webpage redirection. When you add 301 redirects, it sends readers and search engines to a different URL than the one they originally typed into their browser or selected from a search engine results page.

It is far better way than temporary redirect as transfers the inbound links from the redirected domain to the new one. Thus, it helps to maintain site ranking. Check out most important ranking factor.

 302 redirect:

A 302 redirect is a temporary redirect. It actually does not pass on all qualities of the redirected page to the detour page.

You can use this redirect if you want to redirect your readers to another webpage but you plan to bring the redirected page back after some time.

Although, its bit critical to use 302 redirects as it does affects site ranking.

307 redirect:

A 307 redirect is the successor of the 302 redirect. Most of the crawlers treat it as a 302 redirect. The only difference between 307 and 302 is that 307 guarantees that the method and the body will not be changed when the redirected request is made.

Which WordPress Redirection should You Use?

There are various options for doing this. But I recommend 301 redirect as it is preferable for both users and search engines. The engines will also carry any link weighting from the original page to the new URL.

How to Redirect a Page Using Htaccess

  • First, at all, keep a backup of your .htaccess file before making any changes.
  • Next, to edit your .htaccess file, go to FTP. The .htaccess file resides in your WordPress site’s root directory. (How to edit the .htaccess file?)
  • Add following code to .htaccess file.
# Redirecting old post to new post
RewriteEngine On 
Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/

This will add redirection to your old URL.

Another approach to create and manage redirects is by using one of the many WordPress redirect plugins. This will also save your time of writing code.

Here, I have listed best effective plugins that will ease your task.

1. Redirection:

This is the best plugin to easily manage 301 redirect keep track of 404 errors, and generally tidy up any loose ends your site. In other words, it is quite popular and has all the basic features including conditional redirects, full logging and tracking 404 errors.

adding redirect using redirection plugin in wordpress
Adding post/page redirect using redirection plugin in WordPress (Normal mode)

Setting up Redirection plugin:

  • Go to Plugin directory and search for Redirection.
  • Install and Activate the plugin.
  • Now, go to tools from Dashboard menu >> Tools and select Redirection.
  • Paste in the old URL of the page you want to be forward in the box labeled ‘Source URL’.
  • Paste the new URL where you want Google and your visitors to end up in the ‘Target URL‘ field.
  • Hit Add Redirect button.

Now, check if old URL redirecting to the new URL.

The plugin comes with the advanced options which can be seen after clicking on the gear icon next to the Add Redirect button. Below screenshot showing the Advanced Options in the plugin.

Adding post/page redirect using advanced options in redirection plugin in WordPress
Adding post/page redirect using advanced options in redirection plugin in WordPress

Get Plugin

2. Simple 301 Redirects:

It is considered as the easiest way of redirecting requests to another page on your site or elsewhere on the web. Moreover, it allows you to edit PHP header to create a redirect.

Setting up Simple 301 Redirects plugin:

  • Install and activate the plugin.
  • Go to Settings >> 301 Redirects page.
  • There will be two clear boxes to add your OLD URL in Request box and NEW URL in the Destination box.
  • Save changes.

It will automatically add 301 redirection type.

3. Safe Redirect Manager:

It is an HTTP redirect manager for WordPress. Basically, it uses the wp_safe_redirect function which only allows redirects to whitelisted hosts for security purposes.

Setting up the plugin:

  • Install and activate the plugin.
  • Navigate to Tools >> Safe Redirect Manager.
  • At the top of the redirect page, select Create Redirect Rule.
  • Copy and paste the old URL into the “Redirect From” section.
  • Copy and paste the new URL into the “Redirect To” section.
  • Click on Publish.

That’s all we have done by creating WordPress redirection. Hope this guide helped you set up redirects on your site.

You might like to read How to Secure WordPress Blog using the .htaccess method.