301
Moved Permanently
3xx Redirection

What Does HTTP 301 Moved Permanently Mean?

HTTP 301 tells the client that the requested resource has been permanently moved to a new URL. The server includes the new URL in the Location response header. Browsers automatically follow the redirect, and search engines update their index to use the new URL.

This is the most important redirect code for SEO. It signals that all link equity, bookmarks, and references should be transferred to the new URL. Browsers cache 301 redirects aggressively, which means once a user encounters a 301, future requests go directly to the new URL without hitting the old one again.

Common Causes

How to Set Up 301 Redirects

Apache (.htaccess)

# Single page redirect Redirect 301 /old-page.html https://example.com/new-page.html # Redirect entire domain (HTTP to HTTPS) RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Redirect www to non-www RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Nginx

# Single page redirect location = /old-page.html { return 301 https://example.com/new-page.html; } # HTTP to HTTPS server { listen 80; server_name example.com; return 301 https://$server_name$request_uri; } # www to non-www server { listen 443 ssl; server_name www.example.com; return 301 https://example.com$request_uri; }

Express.js (Node.js)

// Single route redirect app.get('/old-page', (req, res) => { res.redirect(301, '/new-page'); }); // Force HTTPS middleware app.use((req, res, next) => { if (req.header('x-forwarded-proto') !== 'https') { return res.redirect(301, `https://${req.header('host')}${req.url}`); } next(); });

Verifying a 301 with curl

$ curl -I http://example.com/old-page HTTP/1.1 301 Moved Permanently Location: https://example.com/new-page Content-Length: 0 $ curl -L -I http://example.com/old-page # Follow redirects HTTP/1.1 301 Moved Permanently Location: https://example.com/new-page HTTP/1.1 200 OK Content-Type: text/html

Common Mistakes to Avoid

Frequently Asked Questions

What is the difference between 301 and 302 redirects?
A 301 is permanent — search engines transfer link equity to the new URL and drop the old URL from their index. A 302 is temporary — search engines keep the old URL indexed. Use 301 for domain changes, URL restructuring, or HTTPS migration. Use 302 for A/B tests, maintenance pages, or geo-based redirects.
How does a 301 redirect affect SEO?
A 301 passes approximately 90-99% of link equity to the destination URL. Google has confirmed that 301 redirects consolidate ranking signals. It is the recommended method for preserving search rankings during URL changes, domain migrations, and protocol upgrades (HTTP to HTTPS).
How do I fix a 301 redirect loop?
First, trace the full redirect chain with curl -L -I <url> to see where it loops. Common causes: conflicting rules in .htaccess (both www and non-www rules active), CDN redirect settings fighting with server-side rules, or a CMS like WordPress forcing a redirect that conflicts with server config. Remove conflicting rules and ensure each URL has exactly one redirect target.

Related Status Codes

Related Tools