301 Moved Permanently
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.
Meaning & Description
Historically, many clients incorrectly changed a `POST` request to a `GET` request when following a 301 redirect. Because of this, it is safer to use a `308 Permanent Redirect` if you need to ensure the HTTP method (like `POST`) is preserved.
Common Causes
- Domain name migration.
- URL restructuring or slug updates in a CMS.
- Enforcing HTTPS or canonical domain names.
How to fix a 301 error
- Inspect the `Location` header to ensure it points to the correct new URL.
- Check for redirect loops (e.g., URL A redirects to URL B, which redirects back to URL A).
- Ensure you are not unintentionally dropping query parameters during the redirect.
- If a `POST` request is being improperly converted to a `GET` request, switch to using a `308 Permanent Redirect` instead.
Browser & SEO Behaviour
Browser Behavior
Browsers transparently follow the redirect and cache the 301 response heavily. The user will see the URL update in their address bar.
SEO Impact
Excellent for SEO. Google passes approximately 100% of link equity (PageRank) from the old URL to the new URL. It signals Google to replace the old URL in the search index.
CDN Behavior
CDNs will aggressively cache 301 responses. A purge is often required if a 301 was issued by mistake.
Code Examples
HTTP/1.1 301 Moved Permanently
Date: Mon, 12 Sep 2026 12:00:00 GMT
Location: https://example.com/new-path
Content-Length: 0app.get('/old-path', (req, res) => {
// 301 ensures permanent redirect
res.redirect(301, '/new-path');
});from fastapi import FastAPI
from fastapi.responses import RedirectResponse
app = FastAPI()
@app.get("/old-path")
def old_path():
return RedirectResponse(url="/new-path", status_code=301)func handler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/new-path", http.StatusMovedPermanently)
}[HttpGet("old-path")]
public IActionResult GetOldPath()
{
return RedirectPermanent("/new-path");
}curl -I http://example.com/old-path
# Adding -L follows the redirect automatically
curl -I -L http://example.com/old-pathRaw HTTP Response Example
HTTP/1.1 301 Moved Permanently
Location: https://example.com/new-path
Content-Length: 0
Connection: closeReal-world Examples
Frequently Asked Questions
What is the difference between 301 and 302?
A 301 is permanent, telling browsers and search engines to update their records. A 302 is temporary, meaning the client should continue using the original URL for future requests.
What is the difference between 301 and 308?
Both are permanent redirects, but 301 historically allowed clients to change a POST request to a GET request. A 308 strictly preserves the original HTTP method and body when following the redirect.
How long does Google take to process a 301 redirect?
It depends on how often Googlebot crawls the old URL. Once crawled, it generally updates the index quickly, but completing a massive site migration can take several weeks.
How do I fix an accidental 301 redirect cached in browsers?
Because browsers cache 301s aggressively, fixing a mistake is hard. You must clear the browser cache locally. To fix it for all users, you often have to create a new redirect from the mistaken target back to the correct URL.
Do 301 redirects pass query strings?
By default, most web servers and frameworks do not forward query parameters automatically unless you explicitly configure them to append the original query string to the new URL.
Did You Know?
Browsers cache 301 redirects so aggressively that they will often skip hitting the server entirely on subsequent visits, directing you straight to the new URL.
For a long time, SEO professionals debated whether 301s lost 15% of link equity. Google eventually confirmed that 301s now pass 100% of PageRank.
Developer Tips
- Never use a 301 redirect for a temporary promotion or maintenance page; use a 302 instead so search engines do not drop the original URL.
- When migrating a domain, keep the old domain active with 301 redirects for at least a year to ensure all search engines and external links have updated.
- Avoid redirect chains (URL A -> URL B -> URL C). Point URL A directly to URL C to improve latency and SEO.
Interview Questions
These are questions you might face in a backend or API design interview that touch on HTTP 301.
Why might a client change a POST request to a GET request when encountering a 301?
In the early days of the web, browsers incorrectly implemented 301 handling for POST requests by changing them to GETs. This became the de facto standard, forcing the creation of the 308 status code to enforce method preservation.
How does a 301 redirect affect SEO link equity?
A 301 redirect transfers all link equity (PageRank) from the old URL to the new URL, making it the safest way to permanently move content without losing search engine rankings.
If you accidentally set up a 301 redirect and it gets cached by a user's browser, how can you force their browser to clear it?
You cannot easily force it remotely without user action (like clearing cache). The best server-side mitigation is to add a new redirect from the mistaken target back to the correct destination.
Common Interview Mistakes
- Failing to mention that 301s can alter HTTP methods (POST to GET).
- Suggesting 301 for login redirects (which should typically be 302 or 303).
- Underestimating the aggressive browser caching behavior associated with 301s.