from Wikipedia, the free encyclopedia

A forwarding ( English forward ) or redirection (English redirect ) in the World Wide Web is used to call a URL (eg. As visiting a website ) to lead to a different URL. A forwarding can e.g. This can be useful, for example, after a website has been relocated or remodeled , in order not to let visitors to an outdated URL fall into the void.

Types of forwarding

There are various options for the technical implementation of forwarding:

Forwarding via HTTP status code

HTTP offers the option of referring to a different URL via the header field . This instructs the web browser to load the specified URL. This is accompanied by a 30x status code. There are different status codes for redirects with different intentions and technical specifications. Location

Status codes for forwarding are specified in RFC 7231 and RFC 2616 (HTTP / 1.1). Different HTTP status codes for redirects are interpreted differently by browsers and search engines. With regard to the intention, a distinction can be made between temporary and permanent forwarding. The technical specification differentiates between aspects such as caching and the request method for the target URL of the forwarding.

The following table shows all forwarding status codes and their technical specifications:

HTTP status code HTTP version Temporary / permanent Cache bar Request method of the second request
301 HTTP / 1.0 Permanent Yes GET / POST can change
302 HTTP / 1.0 Temporary not by default GET / POST can change
303 HTTP / 1.1 Temporary No way Always GET
307 HTTP / 1.1 Temporary not by default like first request
308 HTTP / 1.1 Permanent Yes like first request

The following example shows the HTTP header with a 301 status code:

HTTP/1.1 301 Moved Permanently

Implementation via PHP

The following example shows the HTTP header for a forwarding with status code 301 by a PHP program:

header("HTTP/1.1 301 Moved Permanently");

If a status code is not specified, the 302 status code is used in PHP. Example:


Implementation via rewrite rule

For users of an Apache web server who do not have access to the server configuration but who still have .htaccess activated, it is possible to forward the domain via .htaccess. With this type of forwarding, a .htaccess file is inserted into the root directory of the respective web space with a period and ending. To permanently (see 301-Redirect) every request to z. B. to redirect example.netto the subdomain , the .htaccess file should look like this:

1 RewriteEngine On
3 RewriteCond %{HTTP_HOST} !^www\.example\.net$ [NC]
4 RewriteRule ^(.*)$$1 [R=301,L]

Conversely www., if you want to redirect from the subdomain to the main domain, you would have to adapt the code as follows:

1 RewriteEngine On
3 RewriteCond %{HTTP_HOST} ^$ [NC]
4 RewriteRule ^(.*)$1 [R=301,L]

Forwarding via HTML meta tag

HTML allows forwarding via meta tag , called meta refresh . The web browser is instructed to refresh the page after a specified time or to load a different URL.

With the following command in the header of the HTML file you set a redirection via Meta Refresh:

<meta http-equiv="refresh" content="5; URL=">

Here at you will be to the URL after 5 seconds .

However, this type of forwarding is not recommended by the W3C consortium, for the following reasons: Firstly, the page on which the meta information for forwarding is located is completely loaded so that it can be viewed in full. Second, if the user clicks the back button after successfully redirecting, they will be redirected immediately.

Forwarding in the form of frames

In HTML , so-called frames can be used to display the content of other websites in an embedded manner. This is a kind of frame in which several web pages (HTML documents) can be displayed. The original URL remains visible in the address line of the browser.

There is also the option of integrating content from external websites without having to remove them from their original page by simply integrating the page as a frame (e.g. a Wikipedia article). However, there is currently no uniform regulation as to whether the integration of third-party websites is prohibited or not.

Forwarding via JavaScript

By JavaScript , it is possible the web browser should be instructed to navigate to a specific URL.


<script type="text/javascript">
  window.location.href = "";

Redirects in wikis

In MediaWiki redirects can be created. In this case, the article does not contain any content, only the instruction to redirect to another article page. In contrast to the previous examples, forwarding takes place internally via the wiki engine and not via the browser.

The following command is used to set an internal forwarding in a Mediawiki article:

#WEITERLEITUNG [[Hauptseite]]

Instead #WEITERLEITUNGalso work #Weiterleitung, #weiterleitung, #REDIRECT, #Redirectand #redirect.

When calling up the page, you will be redirected to the main page of the affected wiki.

See also

Individual evidence

  1. ^ SEO & Redirects - The Total Guide . Audisto. Retrieved October 29, 2015.
  2. Automatic forwarding to another address (forwarding) in the Selfhtml wiki
  3. Use standard redirects W3C Quality Assurance Tips
  4. a b Help: Forwarding in the German language Wikipedia