← All Status Codes
301
Moved Permanently
↪️ Redirection Low Risk

📖 What Is HTTP 301?

The resource has been permanently moved to a new URL. Search engines will update their index to the new URL. Browsers will cache this redirect.

🛡️ Security Implications

Open redirect vulnerability if the Location header is constructed from user input without validation. Attackers can redirect users to phishing sites.

🔍 Common Causes

URL structure change, domain migration, HTTP to HTTPS redirect, or trailing slash normalization.

🔧 How to Fix

Verify the Location header is not constructed from user-controlled input. Use a whitelist of allowed redirect destinations.

🖥️ How to Check

curl -I -o /dev/null -w "%{http_code}" https://example.com

HTTP 301 in depth — what you actually need to know

HTTP 301 Moved Permanently signals that the requested resource has been moved to a new URL permanently and that all future requests should use the new URL. The new URL is provided in the Location response header. Clients (browsers, search engines) update their references to the new URL; subsequent requests go directly to the new location.

301 is critical for SEO because search engines treat it as "the canonical URL has changed" — link equity and ranking signals transfer to the new URL. The wrong choice between 301 (permanent) and 302 (temporary) can cause significant SEO damage: using 302 for a permanent move means search engines keep the old URL in their index and do not transfer ranking; using 301 for a temporary move can cause the old URL to be permanently lost from the index.

From a security perspective, 301 redirects can be exploited via open redirect vulnerabilities (attacker controls the redirect destination, used in phishing campaigns to disguise malicious URLs as legitimate ones). HTTP-to-HTTPS upgrades typically use 301 to permanently move users to the secure version. Misconfigured redirect chains (301 to 301 to 301) cause performance and crawl-budget issues.

Five real-world scenarios involving HTTP 301

HTTP-to-HTTPS migration

After enabling HTTPS, redirect all HTTP requests to HTTPS with a 301 (permanent move). Search engines update indexed URLs to https://; browsers cache the redirect. Combined with HSTS header on the HTTPS responses, eliminates the HTTP version entirely.

Site restructuring / URL changes

When changing URL structure (moving content, renaming pages, consolidating sections), 301 from old URLs to new URLs preserves SEO value and prevents broken links. Maintain redirect maps; do not just delete old URLs.

Domain migrations

Moving from old-domain.com to new-domain.com — set up 301 from every old URL to its corresponding new URL. Search engines transfer rankings to the new domain. Maintain the redirects long-term (years) — search engines and bookmarks slowly update.

Canonical URL enforcement

Multiple URLs serving the same content (with/without www, with/without trailing slash, with/without query parameters) should 301 to one canonical version. Prevents duplicate-content SEO issues. Use the rel=canonical link element AND the 301 redirect for redundancy.

Bug bounty — open redirect hunting

Bug bounty hunters specifically test for open redirects in URL parameters. Typical pattern: find URL parameters in the application that look like they might be redirect targets (returnUrl, next, redirect, continue), set them to attacker-controlled URL, observe whether the application redirects without validation. Standard finding for many programs.

Common mistakes & edge cases

Using 302 instead of 301 for permanent moves

Search engines treat 302 as "temporary, keep old URL indexed". Using 302 for a permanent move keeps the old URL ranked instead of transferring rankings to the new URL. Most CMS and frameworks default to 302 unless explicitly told otherwise.

Long redirect chains (301 → 301 → 301 → 200)

Each redirect adds latency (extra round trip). Search engines have crawl-budget limits — long chains waste budget. CDNs and browsers may stop following at 5+ redirects. Audit for chains; consolidate to single redirects.

Not preserving query parameters in redirects

A redirect that strips query parameters loses tracking, search context, and authentication tokens. Default to preserving query parameters unless there is a specific reason to remove them.

Open redirect vulnerabilities in URL parameters

Code that redirects to a URL provided in a parameter without validation enables phishing attacks. Validate against allowlist or use relative URLs only.

Not setting up redirects when changing URLs

Changing URLs without setting up redirects breaks all external links and bookmarks. Search rankings suffer. Always plan redirect maps when changing URL structure.

Redirecting based on User-Agent without considering security

Mobile-specific or browser-specific redirects can be bypassed by changing User-Agent. Do not depend on User-Agent-based redirects for security; use them only for UX (mobile site vs desktop site).

Frequently Asked Questions about HTTP 301

A redirect status code indicating the resource has been permanently moved to a new URL. Clients (browsers, search engines) should update their references to the new URL provided in the Location response header. Future requests should go directly to the new URL.
301 = permanent move, transfers SEO value to new URL, browsers cache the redirect. 302 = temporary move, old URL retains SEO value, browsers do not cache long-term. Use 301 for permanent URL changes; use 302 (or 307) for temporary redirects.
Search engines treat 301 as "the canonical URL has changed" and transfer ranking signals to the new URL. Most modern guidance is that 301 transfers ~all link equity (some debate about exact percentage, but transfer is substantial).
Apache (.htaccess): Redirect 301 /old-page /new-page. Nginx: return 301 /new-page; in location block. WordPress: Redirection plugin or RankMath/Yoast redirects. Code: HTTP response with status 301 and Location header.
A vulnerability where an application redirects to URLs provided in user input without validation. Attackers craft URLs starting with your trusted domain that redirect to malicious sites. Used in phishing campaigns to disguise malicious URLs as legitimate.
Each redirect adds a round trip (latency). Search engines have crawl-budget limits — long chains waste budget. Some browsers stop following after 5+ redirects. Consolidate to single redirects from old URL directly to final URL.
Configure your web server to 301-redirect all HTTP requests to the HTTPS equivalent. Apache: RewriteEngine + condition + rule. Nginx: separate server block listening on port 80 with return 301 https://$host$request_uri;. Combine with HSTS header on HTTPS responses to enforce HTTPS for future connections.
Browsers cache 301s aggressively — sometimes for the entire browser session, sometimes longer. Once a browser has cached a 301, it skips contacting the original URL entirely. This makes accidental 301 to wrong destination painful to fix; the cached redirect persists in browsers.
Technically yes but never do this — downgrades security. Browsers may warn or block. Search engines penalize. Always direct toward HTTPS, not away from it.
Proper 404 returns HTTP 404 status code with not-found body. Soft 404 returns HTTP 200 status code with not-found-style body content. Search engines penalize soft 404s — they look like duplicate "not found" content across many URLs. Use proper status codes.