301 Status Code - Moved Permanently

In this section you will learn about 301 Status Code, what is it, its components and examples.

301 Status Code - Moved Permanently
301 Status Code - Moved Permanently
301 Status Code - Moved Permanently

Luke Stephens

Luke Stephens

Luke Stephens

What is HTTP Status Code 301 - Moved Permanently?

The HTTP Status Code 301, denoted as "Moved Permanently," is a redirection response status code. It indicates that the resource the client is attempting to access has been permanently moved to a different URI, and the client should use this new URI for future requests. This status code is crucial for both search engine optimization (SEO) and user experience, as it seamlessly redirects users and search engines to the updated resource location.

Understanding 301 Moved Permanently

  • Permanent Redirection: When the server responds with a 301 Moved Permanently, it's signaling that the resource has been permanently transferred to a new location. This is a strong directive, indicating that the old URL should not be used anymore.

HTTP/1.1 301 Moved Permanently
  • Location Header: Accompanying the 301 Moved Permanently status code is the Location header, which provides the new URI where the resource can be found.

Location: <https://www.new-website.com/resource>

Why 301 Moved Permanently?

The 301 Moved Permanently status code is instrumental when a website or web resource is permanently transferred to a new location.

Benefits of 301 Moved Permanently

  • SEO Preservation: One of the most significant benefits of a 301 redirect is that it transfers the SEO history and link equity of the old URL to the new one. This ensures that the new URL maintains the search ranking of the old one.

  • User Experience: By using a 301 redirect, users are seamlessly taken to the correct content without encountering broken links or error messages.

How does 301 Moved Permanently Work?

  1. Client Sends a Request:

    The client requests a specific resource from the server using a URL.

GET /old-resource HTTP/1.1
Host: www.example.com
  1. Server Sends a Response:

    The server, recognizing that the resource has been permanently moved, sends a 301 Moved Permanently response, including a Location header pointing to the new URI.

HTTP/1.1 301 Moved Permanently
Location: https://www.example.com/new-resource

Components of a 301 Moved Permanently Response

The key components of a 301 Moved Permanently response are:

  • Status Line: The response's first line, indicating the 301 Moved Permanently status code.

HTTP/1.1 301 Moved Permanently
  • Headers: The Location header is of particular importance as it provides the new URI where the client can find the requested resource.

Examples of 301 Moved Permanently

Website Migration:

GET /old-page HTTP/1.1
Host: www.old-website.com

Response:

HTTP/1.1 301 Moved Permanently
Location: https://www.new-website.com/new-page

In this scenario, a page or an entire website has been moved to a new domain. When users or search engines attempt to access the old URL, they're presented with a 301 Moved Permanently status code and redirected to the new location, ensuring continuity and user experience.

Conclusion

The 301 Moved Permanently status code is an essential tool in the arsenal of web developers and SEO professionals. By indicating a permanent move of a resource to a new location, it ensures that users and search engines are seamlessly redirected, preserving SEO rankings and delivering a smooth user experience. Properly implementing and understanding the 301 Moved Permanently status code is pivotal for anyone involved in website migrations, restructuring, or any scenario where URLs change over time.

Learn about other codes in 3xx family of HTTP status codes such as 302, 304 and 307.