What is a Redirect?
A redirect is a technique that automatically forwards visitors and search engines from one URL to another. When users request the original URL, the server responds with instructions to navigate to a different destination. Redirects are essential for website maintenance, domain migrations, URL restructuring, and preserving SEO value when content locations change.
Types of HTTP Redirects
301 - Permanent Redirect
Indicates the page has permanently moved:
HTTP/1.1 301 Moved Permanently
Location: https://newsite.com/page
- Transfers SEO value (link equity) to new URL
- Search engines update their index
- Browsers may cache the redirect
- Best for permanent URL changes
302 - Temporary Redirect (Found)
Indicates a temporary move:
HTTP/1.1 302 Found
Location: https://temporary-url.com/page
- Does not transfer SEO value permanently
- Search engines keep indexing original URL
- Browsers don't cache as aggressively
- Use for temporary changes only
307 - Temporary Redirect (Strict)
HTTP/1.1 version preserving request method:
- Maintains POST/GET method
- Stricter than 302
- Used for API redirects
308 - Permanent Redirect (Strict)
HTTP/1.1 permanent redirect preserving method:
- Maintains request method like 307
- Permanent like 301
- Modern browsers support
Common Redirect Use Cases
Domain Consolidation
Redirect all variations to primary domain:
example.com → www.example.com (or vice versa)
http:// → https://
oldbrand.com → newbrand.com
URL Structure Changes
When reorganizing website architecture:
/old-page/ → /new-page/
/category/page → /new-category/page
/blog/2020/post → /articles/post
Content Migration
Moving content between platforms or domains:
blog.example.com/post → example.com/blog/post
oldsite.com/* → newsite.com/*
HTTPS Enforcement
Secure all traffic:
http://example.com → https://example.com
Implementation Methods
Server Configuration (Apache)
# .htaccess
Redirect 301 /old-page https://example.com/new-page
# Multiple redirects with RewriteRule
RewriteEngine On
RewriteRule ^old-path/(.*)$ /new-path/$1 [R=301,L]
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Server Configuration (Nginx)
# Single redirect
location /old-page {
return 301 https://example.com/new-page;
}
# Pattern-based redirect
location ~* ^/old-path/(.*)$ {
return 301 /new-path/$1;
}
# Force HTTPS
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
JavaScript Redirect (Client-Side)
// Immediate redirect
window.location.href = "https://example.com/new-page";
// Delayed redirect
setTimeout(() => {
window.location.replace("https://example.com/new-page");
}, 3000);
Meta Refresh (HTML)
<meta http-equiv="refresh" content="0;url=https://example.com/new-page">
*Note: Not recommended for SEO*
SEO Considerations
Best Practices
1. Use 301 for permanent changes: Transfers ranking signals
2. Avoid redirect chains: A→B→C→D slows crawling
3. Update internal links: Point to final destinations
4. Monitor redirect performance: Track in analytics
5. Set up proper canonicals: Complement redirects
Redirect Impact on SEO
| Redirect Type | Link Equity Transfer | Index Update |
|---|---|---|
| 301 | ~90-99% | Yes |
| 302 | Minimal | No |
| Meta refresh | Varies | Slow |
| JavaScript | Limited | Unreliable |
Common Redirect Problems
Redirect Chains
Multiple sequential redirects:
A → B → C → D (Bad: 4 hops)
A → D (Good: Direct)
Redirect Loops
Infinite redirect cycle:
A → B → A → B → ... (Error: ERR_TOO_MANY_REDIRECTS)
Mixed Content Redirects
HTTPS page redirecting to HTTP (or vice versa without proper chain)
Properly implemented redirects are essential for maintaining user experience and search engine rankings during any URL or domain changes.