Sponsored Links

Minggu, 12 November 2017

Sponsored Links

Symmetric vs. Asymmetric Encryption - CompTIA Security+ SY0-301 ...
src: i.ytimg.com

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 with the response. The 301 redirect is considered a best practice for upgrading users from HTTP to HTTPS. RFC 2616 states that:

  • If a client has link-editing capabilities, it should update all references to the Request URL.
  • The response is cachable.
  • 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.


Video HTTP 301



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 a PHP redirect:

Equivalently simple for an nginx configuration:

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

Search engines

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


Maps HTTP 301



See also

  • Hypertext Transfer Protocol
  • List of HTTP status codes

How to do 301 Redirects with .htaccess (& PHP/ASP) - YouTube
src: i.ytimg.com


References


Source of the article : Wikipedia

Comments
0 Comments