Redirects: How To Use, SEO Impact & Types (301 vs 302) (2024)

Redirection is the process of forwarding one URL to a different URL.

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. The threemost commonly used redirects are 301, 302, and Meta Refresh.

Types of redirects

  • 301, "Moved Permanently"—recommended for SEO
  • 302, "Found" or "Moved Temporarily"
  • Meta Refresh

301 moved permanently

A 301 redirect is a permanent redirect that passes fulllink equity (ranking power) to the redirected page. 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 theoryboth 302s and 301s can both pass the same amount of link equity, there are cases where a 301 might pass a stronger canonicalization signalto Google.For cases in which the redirect truly is temporary, a 302 may be the most appropriate.

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:

Start my free trial

SEO best practices

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.

Redirects: How To Use, SEO Impact & Types (301 vs 302) (1)

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:

Redirects: How To Use, SEO Impact & Types (301 vs 302) (2)

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 reliablypass 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. UsingApache mod_rewrite

You can also use Apache mod_rewrite in your .htaccess file for more flexible redirection. For example, here's the code you'd use toredirect from a non-www to a www subdomain.

RewriteEngine onRewriteBase /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:

<?phpheader("Location: https://www.example.com/", true, 301);exit();?>

JavaScript redirects

While you can technically implement redirects using JavaScript, 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. 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>

Put your skills to work

Gauge a Site's Influence with Link Explorer

Link Explorer is a link popularity and backlink analysis tool that lets you research and compare any site on the web.

Redirects: How To Use, SEO Impact & Types (301 vs 302) (2024)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Stevie Stamm

Last Updated:

Views: 6225

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.