Redirects: How To Use, SEO Impact & Types (301 vs 302)
Updated by Chima Mmeje — November 11, 2024.
What is a redirect?
A redirect is a way to send both users and search engines to a different URL from the one they originally requested, known as the requested URL. The three most commonly used redirects are 301, 302, and Meta Refresh.
Why are redirects important?
Redirects are crucial for maintaining a website’s integrity and user experience. When a URL is changed or a page is moved, redirects ensure that users and search engines are directed to the correct page. This helps to avoid 404 errors, which can frustrate users and lead to a poor user experience. By guiding users to the appropriate content, redirects improve user engagement and satisfaction.
From an SEO perspective, redirects play a vital role in preserving link equity and ranking signals. When a page is moved or its URL is changed, a redirect ensures that the search engines transfer the ranking power and trust from the old URL to the new one. This helps maintain the search engine rankings of the redirected page, ensuring that the website continues to perform well in search results. Without proper redirects, a website could lose valuable traffic and ranking positions, negatively impacting its overall SEO performance.
When to use redirects
Redirects are used in various situations to ensure a seamless user experience and maintain SEO value. Here are some common scenarios where redirects are necessary:
- URL changes or page moves: When a URL is changed or a page is moved to a different location, a redirect ensures that users and search engines are directed to the new page.
- Website updates or restructuring: During website updates or restructuring, redirects help guide users to the updated content, preventing them from encountering broken links.
- Domain changes or consolidation: When a domain is changed or multiple domains are consolidated under one URL, redirects ensure that traffic is directed to the correct domain.
- Temporary unavailability: If a page is temporarily unavailable, a temporary redirect (302) can be used to guide users to an alternative page until the original page is back online.
- Website migration: When migrating a website to a new platform or server, redirects help maintain the website’s SEO value by ensuring that users and search engines can still access the content.
By using redirects in these situations, you can lead users to a new page, a page with similar content, or a page that is more relevant to the website. This not only improves user experience but also helps maintain and improve search engine optimization (SEO).
Types of redirects
- 301, “Moved Permanently”—recommended for SEO
- 302, “Found” or “Moved Temporarily”
- Meta Refresh Redirects—executed on the client side and not recommended for SEO
301 moved permanently http status code
A 301 redirect is a permanent redirect that passes full link equity (ranking power) to the redirect target. 301 refers to the HTTP status code for this type of redirect. In most instances, the 301 redirect is the best method for implementing redirects on a website.
302 found
Use 302 redirects when the URL of a resource is changed temporarily. Some of Google’s employees have indicated that there are cases where 301s and 302s may be treated similarly, but our evidence suggests that the safest way to ensure search engines and browsers of all kinds give full credit is to use a 301 when permanently redirecting URLs. This is because while in theory both 302s and 301s can both pass the same amount of link equity, there are cases where a 301 might pass a stronger canonicalization signal to Google. For cases in which the redirect truly is temporary, a 302 may be the most appropriate. Improperly setting up 302 redirects can lead to a redirect loop, where two URLs continually redirect to each other, causing an infinite cycle.
307 moved temporarily
A 307 redirect is the HTTP 1.1 successor of the 302 redirect. While the major crawlers will treat it like a 302 in some cases, it is best to use a 301 for almost all cases. The exception to this is when content is really moved only temporarily (such as during maintenance) AND the server has already been identified by the search engines as 1.1 compatible. Since it's essentially impossible to determine whether or not the search engines have identified a page as compatible, it is generally best to use a 302 redirect for content that has been temporarily moved.
Meta refresh
Meta refreshes are a type of redirect executed on the page level rather than the server level. They are usually slower, and not a recommended SEO technique. They are most commonly associated with a five-second countdown with the text "If you are not redirected in five seconds, click here." Meta refreshes do pass some link equity, but are not recommended as an SEO tactic due to poor usability and the loss of link equity passed.
A meta refresh might look like this:
<http-equiv="refresh" content="0; url=https://example.com/">
Identify critical redirect issues using Moz Pro
Moz Pro's Site Crawl feature uncovers urgent issues such as redirect chains, temporary redirects, and meta refreshes so you can fix them fast. Take a 30-day free trial on us and see what you can achieve:
SEO best practices for implementing redirects
It is common practice to redirect one URL to another. When doing this, it is critical to observe best practices in order to maintain SEO value.
The first common example of this takes place with a simple scenario: a URL that needs to redirect to another address permanently.
There are multiple options for doing this, but in general, the 301 redirect is preferable for both users and search engines. Serving a 301 indicates to both browsers and search engine bots that the page has moved permanently. Search engines interpret this to mean that not only has the page changed location but that the content—or an updated version of it—can be found at the new URL. The engines will carry any link weighting from the original page to the new URL, as below:
Be aware that when moving a page from one URL to another, the search engines will take some time to discover the 301, recognize it, and credit the new page with the rankings and trust of its predecessor. This process can be lengthier if search engine spiders rarely visit the given web page, or if the new URL doesn't properly resolve.
Other options for redirection, like meta refreshes, can be poor substitutes, as they may not as reliably pass the rankings and search engine value like a 301 redirect will.
Transferring content becomes more complex when an entire site changes its domain or when content moves from one domain to another. Due to abuse by spammers and suspicion by the search engines, 301s between domains sometimes require more time to be properly spidered and counted. For more on moving sites, see Achieving an SEO-Friendly Domain Migration: The Infographic
How to implement a redirect
Today, most modern CMS platforms offer solutions and/or plugins to easily handle 301 and 302 redirects. For example, RankMath is a free WordPress plugin that offers redirection as a basic feature. Many hosting and CDN platforms also offer easy redirection management from their admin panels.
301 redirects in .htaccess
A common way of implementing redirects is through an .htaccess file, which runs on Apache servers. Below we've listed some common .htaccess directives for redirection.
1. To redirect an entire domain to a new site:
Redirect 301 / http://www.example.com/
Replace the example domain with your new redirect destination. This will 301 redirect every page on your site to the corresponding URL on the target domain.
2. To redirect a single page
Redirect 301 /oldpage/ http://www.example.com/newpage/
You can use this redirect across different domains, or on your own site.
3. Using Apache mod_rewrite
Apache mod_rewrite is a powerful tool for creating redirects. It allows you to rewrite URLs and redirect traffic to different pages or domains. To use Apache mod_rewrite, you need to have access to your server configuration files and be familiar with regular expressions. You can also use Apache mod_rewrite in your .htaccess file for more flexible redirection. For example, here's the code you'd use to redirect from a non-www to a www subdomain.
RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
For more .htaccess scenarios, the folks at Linchpin SEO have put together a good resource
PHP redirect
Here is an example of implementing a 301 redirect using PHP:
<?php
header("Location: https://www.example.com/", true, 301);
exit();
?>
JavaScript redirect
While you can technically implement a JavaScript redirect, it is not a recommended method for SEO purposes. While testing has shown that Google may interpret JavaScript redirects as 301s, it’s not a given. Because JavaScript is executed client-side, not server-side, there’s no guarantee of Google indexing the redirection properly. Additionally, Google's rendering challenges can lead to outdated URLs being indexed, negatively affecting search rankings. And finally, there’s no way to declare an HTTP status code when using JavaScript for redirection.
While not recommended, the following is an example of how you could implement a redirect in JavaScript:
<script type="text/javascript"> function redirect1(){ window.location = "http://www.example.com/new-url/" } setTimeout('redirect1()', 5000); </script>
Using WordPress plugins
WordPress plugins can be used to create redirects easily and efficiently. There are many plugins available that offer redirect functionality, including Yoast SEO, RankMath, and Redirection.
To use a WordPress plugin to create a redirect, follow these steps:
- Install and activate the plugin: Choose a plugin that suits your needs and install it from the WordPress plugin repository. Once installed, activate the plugin.
- Go to the plugin settings page: Navigate to the settings page of the plugin you installed. This is usually found under the “Tools” or “SEO” menu in the WordPress dashboard.
- Enter the old URL and the new URL: In the plugin settings, enter the URL you want to redirect (the old URL) and the URL you want to redirect to (the new URL).
- Choose the type of redirect: Select the type of redirect you want to use (301, 302, etc.). For permanent redirects, choose 301.
- Save the changes: Save your settings to apply the redirect.
Using WordPress plugins to create redirects is a user-friendly and efficient way to manage URL changes and ensure that your website maintains its SEO value.
Using Wix
Wix is a website builder that allows you to create redirects easily. To create a redirect in Wix, follow these steps:
- Go to the Wix dashboard: Log in to your Wix account and navigate to the dashboard of the website you want to manage.
- Click on “SEO” in the left-hand menu: In the dashboard, find the “SEO” option in the left-hand menu and click on it.
- Click on “Redirects”: In the SEO settings, find the “Redirects” option and click on it.
- Enter the old URL and the new URL: In the redirects settings, enter the URL you want to redirect (the old URL) and the URL you want to redirect to (the new URL).
- Choose the type of Redirect: Select the type of redirect you want to use (301, 302, etc.). For permanent redirects, choose 301.
- Save the changes: Save your settings to apply the redirect.
Using Wix to create redirects is straightforward and ensures that your website maintains its SEO value and provides a seamless user experience.
Put your skills to work
Gauge a Site's Influence with Link Explorer
Additional Articles on On-Site SEO
What Are On-Page SEO Factors?Title Tag
What Are Meta Descriptions and How to Write Them
Show More