Sie sind auf Seite 1von 2

HTTP 301

The HTTP response status code 301 Moved Permanently is used for permanent URL redirection, meaning current links or records
using the URL that the response is received for should be updated. The new URL should be provided in the Location field included
[1]
with the response. The 301 redirect is considered a best practice for upgrading users from HTTP to HTTPS.

RFC 2616 states that:[2]

If a client has link-editing capabilities, it should update all references to the Request URL.
The response is cacheable unless indicated otherwise.
Unless the request method was HEAD, the entity should contain a small hypertext note with a hyperlink to the new
URL(s).
If the 301 status code is received in response to a request of any type other than GET or HEAD, the client must ask
the user before redirecting.

Contents
Example
Search engines
See also
References
Bibliography
External links

Example
Client request:

GET /index.php HTTP/1.1


Host: www.example.org

Server response:

HTTP/1.1 301 Moved Permanently


Location: http://www.example.org/index.asp

Here is an example using a.htaccess file to redirect a non-secure URL to a secure address without the leading "www":

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

Here is an example using aPHP redirect:


<?php
header ("HTTP/1.1 301 Moved Permanently" );
header ("Location: https://example.com/newpage.html" );
exit();
?>

Equivalently simple for annginx configuration:

location /old/url/ {
return 301 /new/url;
}

Search engines
[3][4]
Both Bing and Google recommend using a 301 redirect to change the URL of a page as it is shown in search engine results.

See also
Hypertext Transfer Protocol
List of HTTP status codes

References
1. Google. "Secure your site with HTTPS"(https://support.google.com/webmasters/answer/6073543?hl=en)
.
support.google.com. Google. Retrieved 2016-02-06.
2. Fielding, et al (1999-06). "10.3.2 301 Moved Permanently".RFC 2616, p 61. IETF, June 1999. Retrieved from
https://tools.ietf.org/html/rfc2616#section-10.3.2
.
3. Site Move Tool - Bing Webmaster Help & How-to -https://www.bing.com/webmaster/help/how-to-use-the-site-move-
tool-bb8f5112
4. 301 redirects - Google Webmaster Tools Help - https://support.google.com/webmasters/bin/answer
.py?
hl=en&answer=93633

Bibliography

External links

Retrieved from "https://en.wikipedia.org/w/index.php?title=HTTP_301&oldid=822092671


"

This page was last edited on 24 January 2018, at 10:08.

Text is available under theCreative Commons Attribution-ShareAlike License ; additional terms may apply. By using this
site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of theWikimedia
Foundation, Inc., a non-profit organization.

Das könnte Ihnen auch gefallen