Redirects are a natural part of any website. Pages become obsolete, and content changes or is moved to other pages. You'll learn what redirects are and how to set up redirects correctly.
Table of Contents:
301 redirects: permanent redirects
302 redirects: temporary redirects
1. Redirect via .htaccess file
2. Redirects via WordPress plugin
Avoid internal redirect chains
Find and update link targets with XOVI NOW
Redirects in a nutshell
The URL is the address of a page. If it changes or the page's content is moved to another URL, you'll need to let users and crawlers know the new address. Think of a redirect as a permanent or temporary change-of-address order at the post office.
Imagine page A is no longer available. To prevent users (and crawlers) from ending up on a 404 error page, they are instead ‘rerouted’ to another page B. This ‘rerouting’ is a redirect.
Redirects come in different types (a.k.a. Status codes), and here are two especially important in SEO: Status codes 301 and 302. You'll learn more about them in a minute.
People usually only notice a redirect if they know the URL is different or they’ve visited the page before. Crawlers, however, will always know a redirect when they see one — and they will treat redirects differently depending on their status code.
When do I need a redirect?
The URL is the address of a page. You'll need a redirect when it changes or replaces one page with another. Choose one of the following redirect types depending on the change's duration:
- Temporarily unavailable
- Temporary redirect, status code 302
- Rerouting users to other pages for a limited time
- Permanently unavailable
- Permanent redirect, status code 301
- Pages no longer meet content or SEO requirements and are removed
- Products/services are taken off the portfolio
301 redirects: permanent redirects
As mentioned before, there are permanent and temporary redirects. Permanent redirects reroute from the old URL to the new one. They replace the old page and are the new addresses after a move.
Possible reasons for a 301 redirect:
- New domain/relaunch
- Upgrading from HTTP to HTTPS
- Changing the permalink,
e.g., /p=123/ to /sale/ - Changing the directory structure,
e.g., /2019/06/article/ to /blog/article - Migrating similar articles/content to the same page
- Removal of obsolete content/products/services
301 redirects and SEO
301 is code for: "Moved Permanently." Based on this status code, search engines know that the page:
- is no longer accessible but will be permanently replaced by another one.
- should no longer be indexed, and search engines should include the new page in search results.
301 redirects prevent broken pages (pages with the status code 404), negatively impacting your SEO. After all, 404 errors lead users and crawlers to a dead end. So keep the number of broken pages at a minimum.
|
You can learn how to find and fix broken pages in our guide. |
With a 301 redirect, you provide users and crawlers with a relevant alternative or new ‘address.’ Properly establishing redirects is especially important after a relaunch, where a lot of content is moved around, and most or all URLs are different.
301 redirects pass on so-called link juice from valuable backlinks the replaced page might have.
302 Redirects: Temporary redirects
Temporary redirects are used for temporarily unavailable pages.
Imagine you run a limited-time offer and want to redirect users to that landing page instead of the original page. Or a page is under construction, and you wish to send users elsewhere during that time.
302 redirects and SEO
The 302 status code is "Moved Temporarily." It signals search engines that the original page will be accessible again. That's why search engines won't bother to index the 'new' page. Instead, the original page continues to appear in search results.
|
If you want the new page to appear in search results instead, set up a 301 redirect! |
If a temporary redirect remains in use for a long time, it can confuse search engines as they do not know which page is valid. As a result, they might index both the new and the old pages, causing permanent ranking fluctuation.
|
Create a note in your calendar to remind you when to remove the 302 redirects. |
How do I set up redirects?
Now you know what type of redirect you need, but how and where do you set it up?
There are three ways to set up a redirect:
- Set up a redirect via the .htaccess file
- Set up a redirect via a WordPress plugin
- Set up a redirect via PHP
1. Redirect via .htaccess file
You can write a redirect directly in the .htaccess file on your server. However, this only works with Apache servers.
The .htaccess file is a text document in your server's root directory. It is responsible for redirects, among other things. You need the Apache module "mod rewrite."
- In your server's root directory, download the .htaccess file using an FTP client.
- Create a backup copy of the .htaccess file on your computer before editing the file.
- Open the file in the text editor.
- Enter your redirect(s) BEFORE the line # Start [CMS type], e.g., # Start WordPress
- If no redirects have been set up yet, add the following two lines:
RewriteEngine On
RewriteBase / - Enter one redirect per line. You only need the URL paths and the desired status code (301 or 302).
RewriteRule /oldpath.com /newpath.com [R=30X]
[R=30X] equals the chosen status code. - Save the .htaccess file (do not change the document's title) and upload it to the root directory.
|
Check out this detailed article about .htaccess files, what they are, when you should (not) use them, and how to work with them. |
|
If you feel uncomfortable editing the .htaccess file on your own, use a 301 redirect generator. Enter the URL paths of the old and new pages, and you'll get a working directive that you can paste into your .htaccess file. |
Setting up redirects using the .htaccess file is very inconvenient. After all, you have to download, edit and upload the .htaccess file every time. For temporary 302 redirects, it may not even be worth the trouble.
2. 301 redirects via a WordPress plugin
The redirect setup using a plug is much less hassle, especially for WordPress sites. A plugin lets you create redirects directly in your CMS without needing to access your server.
|
A reliable WordPress plugin for 301 redirects is Simple 301 Redirects, for example. It is free and easy to use. After installation, you can access it under Settings - 301 Redirects. |
The plugin provides you with a list of all existing redirects.
|
Set up a new redirect by first copying the URL path of the old URL into the last empty line, then the path of the new URL. Save your changes, and you are done. |
3. 301 redirects via PHP
For PHP redirects, a code snippet is placed in the HTML header of the page you want to redirect from.
The code snippet for a 301 redirect looks like this:
<?
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.newurl.com” );
?>
This method works but can quickly become confusing. Unlike the .htaccess file or the plugin, you do not have an overview of all the redirects set up on your website.
Testing and revision
After you've set up your redirect, you'll need to check it.
|
Set the old page to Draft so it is no longer accessible and cannot be found by anyone. Now try to access the old page. You should be redirected to the new one. |
Avoid redirect chains
|
Identify which of your website's pages link to the old URL and update the links to carry the new URL. |
Redirect chains negatively affect your SEO and user experience. They can use up your site's crawl budget, the time a search engine dedicates to crawling your website. Not every page might be crawled- and indexed if it is used up to follow redirect chains.
Redirect chains can also reduce page speed because it takes longer to request the page at the chain's end. Low page speed significantly increases the bounce rate, as users tend to get impatient after a few seconds of loading time.
Google's Matt Cutts also advises against redirect chains. A redirect from A to B is ideal, but from A via B, C, and D to E is not.
Find and update link targets with XOVI NOW
The XOVI NOW URL Analysis lists all incoming and outgoing links of a page.
Go to: Projects → Site Audit→ URL Analysis
|
Analyze the old page to get a complete list of inbound links. Go through the internal links list one by one. Update the link destination of the source by replacing the old URL with the redirect URL |
|
If the page has a lot of inbound links, add the Source → Contains filter and enter your domain to narrow down results to internal links only. |
Comments
0 comments
Please sign in to leave a comment.