Nowadays, almost every web page is dynamic and with WordPress blog no doubt, it’s real-time too. You work hard to add new blog posts and pages every time. Not just adding new content, you may be editing an existing blog post too.
There may be a situation where you may need to edit a URL or the link. This may happen for so many reasons like
- when you move to a new domain
- when you change the URL or link of a page
- when you want to create multiple URLs for a single page
For a blog, it’s your own choice you can change whatever you want including the domain name or a change in URL of a specific page.
When you do such a change that affects an existing URL in your blog, for a user who still refers to the old link may get lost. Since you edited the URL, the user may not be aware of it. Even the search engines like Google may not be aware of it until you tell them through an HTTP code.
There comes 301 redirect status code.
What is 301 Redirect? How to use 301 Redirect In Your Blog?
301 Redirect is a method to redirect one URL to another URL.
This redirect shall happen within a domain name or even across domain names.
Let’s us say there are two pages: Page-1 and Page-2
- Page-1 : http://www.example.com/old-url/
- Page-2 : http://www.example.com/new-url/
The requirement is, I want to redirect Page-1 to Page-2 – this can be done using 301 Redirect.
The user requests for Page-1:
GET /index.php HTTP/1.1
The server responses with a 301 Redirect:
HTTP/1.1 301 Moved Permanently
The example source code to perform a 301 Redirect using PHP:
Place the following piece of code on Page-1
header(“HTTP/1.1 301 Moved Permanently”);
Whenever, someone (user or a search engine) accesses the Page-1 they will be redirected to Page-2.
How do you setup a 301 Redirect In WordPress?
With WordPress, there are always plugins that can help us to perform anything with our blog. You can find a lot of plugins from the official directory which can be used to setup a 301 redirect.
You can also setup any number of 301 redirects in your blog. I use this plugin especially if I am editing the URL of a specific blog post or page. The interface of 301 Redirects plugin is also simple.
Let’s get into the steps to setup a 301 Redirect:
- Go to Plugins > Add New
- Search for “Simple 301 Redirects”, Click Install Now and then “Activate Plugin“
- Go to Settings > 301 Redirects
- Let’s take the same example of Page-1 and Page-2. Enter the Slug of Page-1
- Enter the full URL of Page-2
- Click “Save Changes”
Similarly, you can setup any number of redirects in your blog.
This plugin can also redirect to a different domain. The following screenshot shows the 301 redirection setup from Page-1 to a different page on a domain name.
A 301 redirection is the proper way to move a page from one URL to another without any errors or issues. Both the users as well as the search engines are taken to the correct destination URL after a move.
What are the guidelines to create 301 URL redirection?
When you are creating a 301 redirection, make sure you are not messing it up. Because, it badly affects the user experience and also, affects the search engine rankings (may cause a drop in Google traffic if you don’t redirect properly).
The following are the simple to follow guidelines you should keep in mind:
- Always keep the number of redirects to one level.
- If not possible don’t perform redirects more than 2 times.
- Make sure the old URL is not broken especially if it takes an argument (for example http://www.example.com/old-url?id=1207)
- Use a simple URL structure (for example http://www.example.com/download-app.html is a simple one)
Help Videos on 301 Redirect.
In the following video, Matt Cutts explains the limitations in number of redirects.
Yet another video with example which can help you to setup 301 redirect using htaccess file.
Hope these videos are helpful to you.