What Is a 301 Status Code?
The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.
Clients with link-editing capabilities ought to automatically re-link references to the effective request URI to one or more of the new references sent by the server, where possible.
The server SHOULD generate a Location header field in the response containing a preferred URI reference for the new permanent URI. The user agent MAY use the Location field value for automatic redirection. The server’s response payload usually contains a short hypertext note with a hyperlink to the new URI(s).
Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is undesired, the 307 Temporary Redirect status code can be used instead.
A 301 response is cacheable by default; i.e., unless otherwise indicated by the method definition or explicit cache controls1.
- 1 Calculating Heuristic Freshness RFC7234 Section 4.2.2
- Source: RFC7231 Section 6.4.2
301 CODE REFERENCES
Rails HTTP Status Symbol :moved_permanently
Go HTTP Status Constant http.StatusMovedPermanently
Symfony HTTP Status Constant Response::HTTP_MOVED_PERMANENTLY
Python2 HTTP Status Constant httplib.MOVED_PERMANENTLY
Python3+ HTTP Status Constant http.client.MOVED_PERMANENTLY
Python3.5+ HTTP Status Constant http.HTTPStatus.MOVED_PERMANENTLY
.NET HttpStatusCode.MovedPermanently
Rust http::StatusCode::MOVED_PERMANENTLY
Java java.net.HttpURLConnection.HTTP_MOVED_PERM
Apache HttpComponents Core org.apache.hc.core5.http.HttpStatus.SC_MOVED_PERMANENTLY
Angular @angular/common/http/HttpStatusCode.MovedPermanently
301 status code example
Here’s an example of a request and response for a 301 status code:
Request
GET /old-page.html HTTP/1.1
Host: example.com
Response
HTTP/1.1 301 Moved Permanently
Location: https://example.com/new-page.html
Content-Length: 0
In this example, the client sends a GET request for an old page located at “/old-page.html” on the host “example.com”. The server responds with a 301 status code, indicating that the requested resource has been permanently moved to a new location, and providing the new URL in the “Location” header. The client should follow this new URL in order to retrieve the resource, and the server sends a “Content-Length” header with a value of 0 to indicate that there is no content in the response body.
How to fix a 301 redirect
To troubleshoot and fix a 301 redirect, you can follow these steps:
- Identify the redirect: Use a web browser and navigate to the old URL that is being redirected. Check the HTTP status code returned by the server using the developer tools or a tool like Screaming Frog SEO Spider. A 301 redirect will return a status code of 301.
- Check the redirect destination: Make sure that the destination URL is correct and functional by using our free redirect checker tool. Ensure that the new page or website is loading correctly and that there are no errors.
- Update links and references: Update any internal or external links, bookmarks, or references to the old URL with the new URL.
- Implement the redirect: If the redirect is not yet implemented, use server-side configuration or web application code to set up the redirect. This can be done using a .htaccess file or a server-side script. Make sure that the redirect is set up correctly and that it is returning the correct HTTP status code.
- Test the redirect: Use a web browser and navigate to the old URL again. Check the HTTP status code returned by the server and make sure that it is now returning a 301 redirect to the new URL.
- Monitor for issues: Monitor web analytics and search engine rankings to ensure that the redirect is working correctly and that there are no negative impacts on traffic or rankings.
By following these steps, you can troubleshoot and fix a 301 redirect to ensure that users can still find the content they are looking for and that search engine rankings are maintained.
FAQs about 301 redirects
Learn more about 301 redirects with these FAQs:
What causes a 301 redirect?
A 301 redirect is caused by a server or website administrator changing the URL of a web page or website, either by moving the content to a new URL or by updating the website’s structure or architecture. This can happen for a variety of reasons, such as rebranding, consolidating content, or improving the site’s search engine optimization (SEO).
By using a 301 redirect, the administrator informs both users and search engines that the content has been permanently moved to a new location, and any links or bookmarks to the old URL should be updated to the new URL. This helps to ensure that users can still find the content they are looking for and that search engines can update their indexes accordingly.
When should you use a 301 redirect?
A 301 redirect should be used when a web page or website is permanently moved to a new URL.
This is typically done to maintain the page’s search engine rankings and to ensure that users can still find the content they are looking for. A 301 redirect is the best way to inform search engines that the content has been permanently moved to a new location, and that any links or bookmarks to the old URL should be updated to the new URL.
Some common situations where a 301 redirect might be used include:
- Website rebranding
- Website restructuring
- Content consolidation
It is important to ensure that the redirect is implemented correctly to avoid any negative impact on search engine rankings and user experience.
When should you not use a 301 redirect?
A 301 redirect should not be used in certain situations, such as:
- Temporary redirects: If the move is temporary, a 302 or 307 redirect should be used instead of a 301 redirect.
- Redirect chains: Avoid setting up a series of multiple redirects, also known as redirect chains, as they can slow down page load times and cause issues with search engine rankings.
- Incorrect use of redirects: Avoid using redirects as a substitute for proper page content or design. A redirect should be used only to send users to the correct page.
- Domain changes: If there is a domain name change, it may be more appropriate to use a domain level redirect, such as a 301 redirect at the DNS level, instead of a URL level 301 redirect.
In summary, a 301 redirect should not be used in situations where it is not appropriate or where other types of redirects are more suitable. It is important to use the appropriate redirect type to ensure that users and search engines are directed to the correct page and that there are no negative impacts on website traffic or rankings.
What is the difference between a 301 and 302 status code?
A 301 status code is a permanent redirect to a new URL, while a 302 status code is a temporary redirect to a new URL. The client should update bookmarks and links for a 301 redirect, but continue to use the old URL for a 302 redirect. The difference between the two codes is in their intended meaning and behavior.
Additional resources
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs
- W3Schools
Marketing Tips for Niche Industries
- Trucking Website Design Services That Help You Grow Online
- Web Design for PPE Companies: 5 Sales-Boosting Design Tips
- Web Design for Exercise Equipment Companies: Browse Services & Get Tips
- Web Design for Storage Facilities: Launch a Revenue-Driving Site
- Web Design for Pressure Washing Companies
- Web Design for Restoration Companies (+4 Tips for Success)
- Web Design for Flooring Companies
- Web Design for Biotech Companies: How to Design a Biotech Site
- Web Design for Window and Door Companies: Inspire Your Site
- Web Design for Robotics