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 or server maintenance. With a 301-redirect, duplicate content can, for example, be avoided.

Background[edit]

A redirect is always usually automatic and is hardly perceived by a user. Especially on the server side, automatic redirects are ideally suited to redirect URLs without usability being impaired.

Server-side redirects[edit]

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, the server will immediately redirect to the new destination.

301 redirect[edit]

The 301 redirect is a way to permanently forward a URL. This redirect is ideal for the re-launch of 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.

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.domain.com/the-new-name.php");
header("Connection: close");
?>

302 redirect[edit]

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[edit]

With the 307 redirect, you can 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[edit]

With redirects in this form, 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 in terms of search engine optimization.

Meta refresh[edit]

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[edit]

A redirect via JavaScript is recommended only conditionally. Firstly, it is presumed with this redirect that the user’s browser has JavaScript enabled and such redirects are often interpreted by the search engines as cloaking or URL hijacking.

If a redirect is done using JavaScript, it may look like this.

document.location.href = 'index.html'

Possible hazards[edit]

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, with which 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[edit]

A redirect is useful for search engine optimization in many ways.

  • Dead links can be redirected to a new destination by 301 redirect.
  • With the permanent redirect to a URL, with www to the version without www or vice versa, double content can be avoided.
  • Users can be alerted to a server maintenance per 307 redirect. Thus a poor user experience is avoided.
  • By using 301 redirects for the relaunch of a website, link juice loss can be avoided. At the same time, redirecting prevents dead links from occurring.
  • If a redirect is used, no PageRank will be 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.

Web Links[edit]

  • Planning on moving to https? Here are 13 FAQs plus.google.com Abgerufen am 28.08.2017
  • 301 Redirects Rules Change: What You Need to Know for SEO moz.com Accessed on 02/01/2017