How to Set Up Domain Redirects Properly (301 vs 302 Explained)

Claudia Avatar
How to Set Up Domain Redirects Properly (301 vs 302 Explained)

Redirects are the silent engineers of the web. Whether you’re moving from www to non-www, switching to HTTPS, or rebranding your domain, proper redirects decide whether your SEO authority travels with you-or disappears.

A poorly configured redirect can break indexing, split traffic, or waste valuable backlinks. This guide explains what each redirect type means, when to use it, and how to implement them the right way.

What Is a Redirect?

A redirect tells browsers and search engines that a URL has moved. When a user visits the old URL, the server responds with a 3xx HTTP status code and forwards them to the new location.

Common Use Cases

  • Domain migrations (e.g., example.netexample.com)
  • HTTPS upgrades (http://https://)
  • Canonical version control (wwwnon-www)
  • Content restructuring or page merges

Without redirects, visitors hit 404s, and search engines lose trust.

Understanding 301 vs 302 Redirects

301 Redirect – Permanent Move

  • Signals that the old URL is gone for good.
  • Passes ≈ 90–99 % of link equity (PageRank).
  • Updates index to the new destination.
  • Cached by browsers and search engines.

Use for:

  • Domain migrations
  • HTTPS enforcement
  • Canonical consolidation
  • Permanent URL changes

302 Redirect – Temporary Move

  • Indicates a short-term change.
  • Does not transfer full SEO authority.
  • Search engines keep the original URL indexed.
  • Useful for A/B testing, maintenance, or location-based routing.

Use for:

  • Limited-time campaigns
  • Staging or beta pages
  • Seasonal offers

SEO Impact Summary

Factor301 (Permanent)302 (Temporary)
Link Equity Transfer✅ Full⚠️ Partial / None
Index Update✅ New URL⚠️ Old URL retained
Caching by Browsers✅ Yes⚠️ Limited
Ideal ForMigrations & HTTPSTesting & Short-Term Moves

How to Set Up a 301 Redirect

Implementation depends on your server environment.

1 – Apache (.htaccess)

RewriteEngine On
# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

2 – Nginx

server {
listen 80;
server_name www.example.com;
return 301 https://example.com$request_uri;
}

3 – WordPress / CMS

Use the “Site Address” and “Home URL” settings or a plugin like Redirection for page-specific rules.

4 – Cloudflare / CDN

Create a Page Rulewww.example.com/*https://example.com/$1 (status: 301)

How to Set Up a 302 Redirect

Apache

Redirect 302 /old-offer https://example.com/new-offer

Nginx

rewrite ^/old-offer$ https://example.com/new-offer redirect;

Testing Your Redirects

  1. Browser Test: Visit the old URL; confirm auto-forward to the new one.
  2. Command Line: curl -I https://oldurl.com → check HTTP/1.1 301 Moved Permanently.
  3. Crawlers: Run Screaming Frog or Sitebulb to ensure no redirect chains (>1 hop).
  4. Google Search Console: Inspect the new URL → “URL is on Google.”

A single-hop 301 redirect is best for speed and authority.

Avoiding Redirect Mistakes

MistakeEffectFix
Using 302 for permanent movesLink equity lostReplace with 301
Chain redirects (>2 steps)Crawl inefficiencyConsolidate rules
302 + HTTPS mismatchDuplicate indexingMerge to one 301
Redirect loopSite inaccessibleTest configs with curl -I -v
No canonical tagMixed signalsAdd canonical to final URL

301 Redirects and Analytics Data

Because 301s are cached, they preserve referral and campaign data accurately across platforms.
302s can break tracking sessions, causing analytics drops. For SEO and reporting integrity, 301 is preferred for permanent migrations.

HTTP to HTTPS Redirect

Modern browsers flag non-HTTPS sites as insecure. Redirect all HTTP traffic to HTTPS using 301:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

Benefits:

  • SEO Boost (Google ranking signal)
  • User Trust (lock icon)
  • Analytics Integrity (referrer data preserved)