Redirects: Which Ones to Use and How to Set Them upHow to
In this post we will talk about the most common redirects and issues they may cause with entertainment allusions ;) Also, I’ll explain how to prepare a list of redirects for moving to another website engine (CMS). Sounds interesting? Let’s get this sorted out.
1. What Is a Redirect?
Redirect leads both users and search engines to another URL instead of requested one. So you have to know what you need them for, where do they lead and which type of them do you have to set up.
2. Types of Redirects and What They Are Needed for
You should clearly understand the purpose of each redirect on your website and choose the most appropriate one. Browsers and search engine robots determine redirect type according to the HTTP status code. Redirects have different HTTP statuses (301, 302, 303, 307) and in this post we will talk about them in details.
More about HTTP status codes read in our blog post.
To make changes in the .htaccess file you should access the file via FTP client, for example, FileZilla. You can see a detailed example of redirect implementation in the .htaccess file in our post about switching to HTTPS.
2.1. 301 Redirect Moved Permanently
301 redirect is a permanent redirect usually used for saving link juice when the web page has been moved to a new address and the old URL is out of date. As Matt Cutts once said, pages with a 301 redirect lose as much link juice as a simple link (almost 10%). However, it’s the most reliable way of redirection if you crave to save almost all link equity on your web page.
Cases of Using 301 Redirect
We have gathered common cases of using 301 redirect and code examples for Apache server.
This is how to set up redirect from domain with www to the domain without www:
And this is how you redirect URL without www to the URL with www:
Сhanging File Extension
If you have moved to another platform or CMS and in this process only URL extensions were changed, you should use the following redirect.
Redirection from Different Domains and Subdomains
If you have bought several domains in different domain zones or have been redesigning a new website on a subdomain, you should redirect all additional domains or subdomains to the primary domain:
Now all domains such as www.bacon.us, www.bacon.net, fried.bacon.com will be redirected to www.bacon.com.
Slashes at the End of the URL
You should remember that search engines consider URLs with and without slash (https://www.bacon.com/sandwich/ and https://www.bacon.com/sandwich) as two different URLs. Decide which one is more appropriate for your website and set up the following redirects.
To remove a slash at the end of URL:
To add a slash at the end of URL:
Switching from HTTP to HTTPS
You need to set a redirect instruction for the 301 redirect to HTTPS version of the website. If you have WordPress CMS with hosting controlling by cPanel, you can read a detailed guide on moving to HTTPS.
Fixing broken links
If you’ve permanently deleted one of your pages and created a new one instead, set 301 redirect to the main or new page and remove all links within your website leading to the nonexistent one.
And make sure to check out our detailed post about broken links.
2.2. 302 Found (HTTP 1.1) / Moved Temporarily (HTTP 1.0)
302 redirect is a temporary one. So it can be used while testing new pages or website redesigning. This type of redirects is not appreciated in SEO because it’s generally believed among SEO specialists that it loses PageRank. But Gary Illyes is certain that it doesn’t. To verify this statement, Dan Kern conducted an experiment and found out that 302 redirect indeed passes PR.
There are different response statuses for two versions of 302 redirect:
- HTTP 1.0: 302 response status code is ‘Moved Temporarily’. It means that current document is temporarily moved to a different URL.
- HTTP 1.1: 302 response status code ‘Found’ – current document was found with another address.
You can write such directive in .htaccess file to set it:
2.3. 307 Moved Temporarily (HTTP 1.1 Only) and 303 See Other
These redirects were created to eliminate ambiguity with 302 redirect.
You can implement ‘307 Moved Temporarily’ when the content is moved only temporarily (for example, during redesigning). It lets search engines know that your server is compatible with HTTP 1.1.
Moreover, clients should not follow the redirect automatically for POST/PUT/DELETE requests. Caching should be performed only if there are Cache-Control or Expires headers in the server response.
Along with 307 redirect, 303 redirect was released. It’s used quite rarely. For example, when the user is searching for the one type of document on the website and another type was found. In this case, instead of showing this document in search results, you can use 303 redirect to point to the user the document found in the Location header. Then the user will immediately see what he is searching for without viewing search results. Users for this resource should follow the redirect for POST/PUT/DELETE requests, but use GET for the follow-up request. This redirection is not allowed for caching.
2.4. Meta Refresh
According to W3C: 'In HTML and XHTML, one can use the meta element with the value of the http-equiv attribute set to "Refresh" and the value of the content attribute set to "0" (meaning zero seconds), followed by the URI that the browser should request. It is important that the time-out is set to zero, to avoid that content is displayed before the new page is loaded. The page containing the redirect code should only contain information related to the redirect.'
3. How to Prepare the List of Redirects for Moving to Another Website Engine (CMS)
When you are redesigning your website or moving to another CMS, you should prepare the list of redirects. Why? Because if you don’t want to commit your website’s suicide, make sure that your content is delivered to your user and link juice is saved.
In such cases as moving to another CMS, URL structure is usually different from the previous website version. Of course, we need to save all URLs in search and preserve link juice as much as possible. And 301 redirect can help in this situation. But what to do if there are dozens of thousands of pages on your website? It is usually difficult to write universal redirection rules. Moreover, issues connected with redirections can be very harmful to your website.
To carry out this time-consuming task you can use Netpeak Spider and gather all URLs from your website:
- Choose crawling mode ‘Entire Website’ (in ‘General’ tab of ‘Crawling Settings’) and select ‘Crawl All Subdomains’.
- Select all content types and URLs from the tag.
- Parameters can be left by default.
- Untick the following indexation instructions in ‘Advanced’ tab. Now you won’t miss any web page, if it has URL ;)
After that start crawling. As soon as it’s finished, export received data, move URL column to a new sheet, sort it alphabetically and fill the second column with new addresses.
Just to be on the safe side, you must set redirects on web pages with backlinks. You can use such tools as Majestic and Ahrefs to find them.
4. Redirect Issues
Here is a list of the common issues connected with redirects. Try to avoid them like a plague.
- Redirect to 4xx Error Page. Don’t forget that the main purpose of redirects is to lead users and search engines to the working URL despite all changes at the website.
- Redirect to irrelevant pages/content. Don’t upset your users and set up redirects to the web page with the content they are looking for.
- Endless redirect. It indicates all pages redirecting to themselves and thereby generating infinite redirect loop. It can occur because of the mistake in htaccess file.
- Any multi-step redirects. Try not to use them because they slow down loading speed and make your pages lose link juice.
- Redirect blocked by Robots.txt. In such case, URL you are redirecting to will be missed by search engines.
- Redirect with bad URL format in HTTP response headers.
After implementing redirects, check your website and see results. Netpeak Spider can help you identify all issues connected with them on your website. Make sure to choose ‘Redirects’, ‘Redirect Target URL’ and ‘Status Code’ in ‘Parameters’ tab in ‘Crawling Settings’ before crawling. And there is a little feature hiding here. Only status codes that are present on your website will be displayed, nothing redundant ;)
And FYI, our crawler indicates error ‘Max Redirections’ (all URLs redirecting more than 4 times) but you can change the maximum number of redirects Netpeak Spider has to follow in the 'Restriction' tab of ‘Crawling Settings’.
5. In a Nutshell
- Redirects lead users and search engines to another URL instead of requested one. The most common types are 301, 302, 303, 307 and Meta Refresh.
- They are used for different purposes:
- 301 – for permanently moved content or web page, to put together domains with and without www, slashes at the end of the URL, switching to HTTPS and fixing broken links.
- 302 and 307 are used for temporary moving.
- 303 See Other is a special redirect indicating that the requested document was found. But you should use GET method, regardless of the method the original document was requested with.
- And finally Meta Refresh. It is not recommended for SEO because it doesn’t pass link juice and is widely used by spammers.
- In case if you need to prepare list of redirects for moving to another CMS Netpeak Spider can gather all internal redirects of your website.
- And of course after all implementations you should re-check redirects on your website. With Netpeak Spider you can find such issues connected with them as redirect to 4xx error page, endless redirect, redirect blocked by Robots.txt and redirect with bad URL format.
We hope this information will be helpful for you, so if you have any questions or want to share your own experience, don’t hesitate to drop us a line in comments below ;)