301 redirects are generally needed when you change/update your post’s actual URL for some reason or want to redirect WordPress page to another URL. It also includes when you forgot to set pretty permalinks in WordPress and want to do it now.
See our guide how to change permalinks in WordPress for more details.
It is also true if you are moving from one domain name to a new domain name.Woopoo's Tip
The problem here is once you update a URL structure (permalink) of your post, all the internal links to this post will get broken. Any social shares you got will return 404 error “Page Not Found” and any SEO you have done for this post will be lost.
The answer is a 301 redirect. As the name suggests, it will automatically redirect all visitors to the new URL without letting them even know about the move. It will be a totally seamless process.
For search engines and crawl bots, 301 redirect means the page has been permanently moved to a new address. As soon as they encounter a 301 redirect on your WordPress post, they will update search engine’s database with the new address without losing any sweet SEO and page ranking.
The 301 redirection can be implemented using .htaccess file in your blog or by using a redirect plugin in WordPress. We will see both methods.
WordPress 301 Redirect using .htaccess
.htaccess is a file located in the root directory of your blog. see our detailed article how to find and use .htaccess file in WordPress for more details.
Adding 301 redirect with .htaccess needs a bit of code to add to the file. Edit the file and add the following code at the end:
# BEGIN 301 Redirects Redirect 301 /old-url/ /new-url/ # END 301 Redirects
Everything comes after # means its a comment and not a part of code. Redirect 301 is the directive we have used in .htaccess to make the move from relative path old URL to new URL.
You can implement 301 redirects to another website also, the redirect module code will look like:
# BEGIN 301 Redirects Redirect 301 /old-url/ http://learningcms.com/new-url/ # END 301 Redirects
301 Redirect using a plugin
Now we will use a WordPress plugin to implement 301 redirect. It will be as efficient as using .htaccess and you don’t need to know any code. Even beginners can do it without any problem. Let’s fire the process.
- From your WordPress dashboard > plugins, install and activate Redirection plugin.
See our guide how to properly install a plugin in WordPress if you need help.
- The plugin settings will be available under your WordPress dashboard > Tools > Redirection.
- Write your post’s old URL in Source URL. Write your post’s new URL in Target URL and press Add Redirect button.
- You have just enabled a 301 redirect on your WordPress post.
- Visit your post in browser with old URL and you will automatically redirected to the new URL permalink.
We hope you found the article helpful. Enabling 301 redirect in WordPress is a great way to save your blog from 404 page errors and preserve your post’s SEO.