A technique used to send website visitors from one URL to another, often used to handle page migrations or broken links.
What is a redirect?
In standard Web navigation, redirecting is the act of sending the user and the search engine to a different URL than they originally requested. 301, 302, and Meta Refresh are the most commonly used redirects.
Various redirection types
- For search engine optimization, use 301, “Moved Permanently”
- The item has been temporarily relocated or located 302.
- Updated Metadata or Meta Refresh
301 moved permanently
With a 301 redirect, all links from the old site (link equity) are passed to the redirected one. This type of redirect uses the 301 status code. It is best to implement 301 redirects on your website if you need to implement redirects.
302 found
For temporary changes in URLs, use 302 redirects. It’s possible to decide which URLs should be treated equally by search engines and browsers, but our evidence shows that the use of 301s is the most effective way of providing full credit to search engines and browsers of all kinds. Though both 302s and 301s are theoretically able to pass the same amount of link equity to Google, there are situations in which 301s might have a stronger canonicalization signal. It may be more appropriate to use a 302 if the redirection is only temporary.
307 moved temporarily
307 redirects are successors to 302 redirects in HTTP 1.1. It is best to use a 301 in almost all cases, though major crawlers might treat it as a 302 in some cases. 1.1-compliant servers may be detected by search engines even if the content is really only moved temporarily (such as during updates). Adding a 302 redirect for temporarily moved content is generally advisable since there is no way to determine whether a page is compatible with the search engines.
Meta refresh
In contrast to server-side redirects, meta refreshes occur at the page level instead of at the server level. Generally speaking, they aren’t recommended SEO techniques since they’re slow. Commonly, these are associated with a five-second countdown, followed by the message “If you don’t act now” redirected in five seconds, click here.” In theory, meta refreshes do pass link equity, however, their poor usability and diminished link equity make them unrecommended for SEO.
A meta refresh might look like this:
<http-equiv=”refresh” content=”0; url=https://example.com/”>
- SEO Learning Center
- On-Site SEO
- Redirects
SEO best practices
Redirecting one URL to another is common practice. If you want to maintain the SEO value of your work, you have to follow best practices.
As a simple example of this, consider a URL that will permanently redirect to another address through one of the above methods.
Users and search engines alike prefer the 301 redirects over the other options for doing this. A 301 attests that a page has moved permanently to both browsers and search engine bots. In search engine interpretation, it means the page has moved to a new URL, but that the content — or an updated version of it — is also available there. The engines will disperse any link value from the original page to the new URL, as described below:
301 redirects require some time for search engines to discover and recognize, so do not expect to see the old rankings and trust credited to the new page right away. If search engine spiders rarely visit the website involved, or if the modified URL is not properly resolving, this process may take longer.
A 301 redirect is an excellent substitute for meta refreshes, which may not pass rankings and search engine value like a 301 redirect will.
Whenever a site’s domain changes or when content is transferred between two domains, the process of transferring content becomes more challenging. Search engines sometimes take longer to spider and count 301s between domains due to abuse by spammers and suspicion by the search engines.
A guide to redirecting your traffic
301 and 302 redirects can be easily managed by most modern CMS platforms today via plugins and/or solutions. RankMath, for example, provides redirection as a core feature of its free WordPress plugin. In addition to easy redirection management on their admin panels, most hosting and CDN platforms offer a system for redirecting users.
301 redirects in .htaccess
.htaccess files are commonly used by Apache servers to implement redirects. Our list of common .htaccess redirection directives are stated below
1. To redirect an entire domain to a new site:
Redirect 301 / http://www.example.com/
Your new redirect destination should replace the example domain. 301 redirection will be implemented throughout your entire site to the target URL.
2. To redirect a single page
Redirect 301 /oldpage/ http://www.example.com/newpage/
This redirect works across multiple domains, as well as on your own website.
3. Using Apache mod_rewrite
For more flexible redirection, Apache mod_rewrite can also be used in the .htaccess file. You could, for instance, redirect a non-www domain to a www subdomain using the following code.
RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
PHP redirect
Here is an example of implementing a 301 redirect using PHP:
<?php
header(“Location: https://www.example.com/”, true, 301);
exit();
?>
JavaScript redirects
Despite the fact that JavaScript technically can implement redirects, it is not the best method for SEO. XML redirects from JavaScript may be interpreted by Google as 301s. However, it’s still not a certain thing. The redirection cannot be indexed by Google properly because JavaScript runs client-side, not server-side. Additionally, redirection using JavaScript is not possible due to the absence of HTTP status codes.
JavaScript includes several mechanisms for implementing redirects, which are not recommended. Here is an example:
<script type=”text/javascript”> function redirect1(){ window.location = “http://www.example.com/new-url/” } setTimeout(‘redirect1()’, 5000); </script>