Redirect
A redirect (abbreviation for redirection) is a server- or client-side automatic forwarding from one URL to another URL. Redirects are used for various purposes such as the relocation of a website to a new domain, temporarily forwarding traffic during server maintenance, merging duplicate content, and to relocate website visitors from old, out-of-date content pieces to new pages.
>> Redirects: A complete guide on how to do them <<
Background
A redirect is always automatic and is hardly perceived by a user. Particularly on the server side, automatic redirects are an ideal way to forward a user from one URL to another without affecting usability.
Server-side redirects: A summary
With this form of redirect, a corresponding command is entered in the htaccess file on the server (mostly with Apache-Servers). If the URL is called up, the server will immediately redirect to the new destination.
301 redirect
The 301 redirect should be used to permanently forward a URL. For example, a 301 redirect is ideal for relaunching a website, to redirect old URLs that are no longer valid to new URLs. The great advantage of the 301 redirect is that this redirect passes on nearly 100 percent of the link juice and gives a clear indication to search engines that the required resource can permanently be found on another URL.
301 redirects can be implemented either by changing the .htaccess file or using PHP.
This code is used for the .htaccess file:
RewriteEngine on rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
If the 301 redirect is implemented using PHP, the code to be used should look like this. It is entered directly in the source code of the document to be redirected.
<?phpheader("HTTP/1.1 301 Moved Permanently");header("Location: http://www.domain.com/the-new-name.php");header("Connection: close");?>
302 redirect
With the 302 redirect, pages were permanently redirected to the HTTP version 1.0. However, it was rumoured that this routing can not pass on the PageRank. Meanwhile, 302-redirects now also have full Link Power, as Google's John Müller indirectly confirmed in his Google+ Post.[1]. In version HTTP 1.1, the HTTP status code now simply says “found,” which means that the requested resource is available on the server.
307 redirect
The 307 redirect can be used to temporarily redirect a website. This is frequently done when a server is being serviced.
For this purpose, a php file is written in which a message for visitors to the site will be entered. This file is then stored in the root directory. Then a new .htaccess file needs to be created which is named htaccess.307.
One possible solution would look like this:
RewriteEngine On Rewrite Base / RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123$ RewriteCond %{REQUEST_URI} !^/307\.php$ RewriteRule ^(.*)$ http://www.your-site.com/307.php [R=307,L]
The server displays the Statuscode 307, and redirects the URL temporarily.
Client-side redirects: A summary
With client-side redirects, no changes have to made to the server because the redirects are stored directly in the source code of the page. Nevertheless, client-side redirects are not recommended for search engine optimization.
Meta refresh
This redirect is set up by placing a meta tag in the header of the HTML document.
This tag looks as follows:
<meta http-equiv="refresh" content="0;url=http://www.newsite.com/">
A meta refresh is executed on the client, i.e. the browser. Although this form of redirect can be set up quickly, it has disadvantages in terms of SEO and usability.
Users have to wait several seconds before being redirected to the new page. Additionally, these redirects pass on link juice to the target page.
Redirect via JavaScript
Redirects can also be implemented with JavaScript, but this is not recommended, as for this to work, a user's browser must have JavaScript enabled. Search engines also often interpret such redirects as cloaking or URL hijacking.
If a redirect is done using JavaScript, it looks like this.
document.location.href = 'index.html'
Risks
With a client request, every redirect causes an additional step for the server. All redirects are written in htaccess data which have to be loaded new with every server. For this reason, webmasters and SEOs should not use unnecessary redirects, as they could limit the performance of the website.
Furthermore, redirect chains, where many redirects are connected to each other, should be avoided. If there are too many, Google will not be able to follow the redirects and the crawler will receive an error.
Benefits for SEO
A redirect is useful for search engine optimization in many ways.
- Dead links can be redirected to a new destination with a 301 or 302 redirect.
- With the permanent redirect to a URL, with www to the version without www or vice versa, duplicate content can be avoided.
- Users can be alerted to a server maintenance per 307 redirect, helping avoid a poor user experience.
- By using 301 redirects for the relaunch of a website, link juice loss can be avoided. At the same time, redirects prevents dead links from occurring.
- Using redirects means no PageRank is lost.[2]
- With a 301-redirect, websites can redirect from a protocol like http to https.
- In Affiliate marketing, tracking links can be redirected from the affiliate program to the actual landing page.
- With a permanent redirection, a website with geo-localization can be redirected automatically to the version with the appropriate language.
References
- ↑ Planning on moving to https? Here are 13 FAQs plus.google.com Accessed on August 28, 2017
- ↑ 301 Redirects Rules Change: What You Need to Know for SEO moz.com Accessed on January 2, 2017
Web Links
- Matt Cutts On the question: What percentage of PageRank is lost through a 301 redirect?
- How to create a 301 redirect map for site redesigns?
- Instructions for changing the htaccess file for Apache servers