Skip to main content

Domain Redirect: 301, 302 and How to Configure in cPanel

Domains · 19.04.2026 · 4 min read
Illustration for “Domain Redirect: 301, 302 and How to Configure in cPanel”

A domain redirect automatically sends the user and search engine crawlers from one URL to another. Choosing the right redirect type matters, or you can lose accumulated SEO authority or end up with a chain that slows down the site. The mistake is costly: indexing the new address can stretch out for months if the search engine decides the redirect is temporary.

Types of redirects

CodeTypeSEOWhen to use it
301PermanentPasses ~99% of authoritySite move, permanent domain change
302TemporaryDoes not pass authorityA temporary promotion, an A/B test
307Temporary (HTTP/1.1)Does not pass authorityModern-server equivalent of 302
308Permanent (HTTP/1.1)Passes authorityEquivalent of 301, preserves the request method

Do not use 302 instead of 301 for a permanent site move. Google will not transfer PageRank to the new URL, and the old domain will keep competing with the new one in the results for a long time.

Redirecting in cPanel

  1. cPanel → Domains → Redirects
  2. Type: Permanent (301)
  3. Domain: pick the source domain
  4. Redirect URL: enter the target URL
  5. Click Add

Redirecting through .htaccess

# Redirect the whole domain to another one
RewriteEngine On
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]

# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

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

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

Important for SEO: pick one canonical version of the domain (with or without www) and set up a permanent 301 redirect from the other. Google should index only one version, or it splits the page's weight between the two URLs.

Common errors explained

  • ERR_TOO_MANY_REDIRECTS — a rule in .htaccess redirects the domain to itself because of a wrong RewriteCond condition; test the pattern against the real value of %{HTTP_HOST}, not just in theory.
  • 404 after a redirect with URL parameters — a rule like RewriteRule ^(.*)$ .../$1 without handling the query string drops everything after the question mark; add the QSA flag if the parameters need to survive.
  • The redirect works in the browser but not for the search crawler — the server returns code 200 instead of 301 for the Googlebot User-Agent; check with curl -A "Googlebot" -I, not just with a regular browser.
  • Mixed content after the HTTPS redirect — some resources on the page (images, scripts) still load over HTTP; the browser blocks them and shows an insecure-connection warning.

Redirect chains and how to avoid them

A redirect chain (A to B to C to D) slows down loading and loses SEO weight at every link. Always set up a direct A-to-D redirect, skipping the intermediate steps.

# Bad: a chain
old.example.com -- example.com -- www.example.com

# Good: a direct redirect
old.example.com -- www.example.com

Comparing redirect setup methods

MethodAccess neededTime to take effectBest for
cPanel RedirectsControl panelInstantA simple redirect for the whole domain
.htaccessFTP/SSH to the site filesInstantFlexible rules, conditions, parameters
DNS redirect at the registrarDomain panelUp to 24-48 hours (TTL)A domain with no hosting behind it

When 301 does not fit

  • Content is temporarily unavailable at the original URL (maintenance, a seasonal page) — this calls for a 302 or 307, so the search engine does not drop the old address from the index permanently.
  • The site is migrating to a new domain that has not passed SSL setup yet — it is better to set up and verify HTTPS on the new domain first, then apply a permanent 301, instead of redirecting users to a certificate error page.
  • The redirect should only apply to some users (by geolocation, for example) — that is not a job for an HTTP redirect; that logic belongs at the application level or in Cloudflare rules, not in a static .htaccess file.

How to verify the redirect is set up correctly

# Check the response code and the final URL
curl -IL http://old.example.com/
# Expect exactly one hop: HTTP/1.1 301 -- Location: https://www.example.com/

# Check that request parameters survive
curl -IL "http://old.example.com/page?ref=email"

# Check the redirect through the eyes of the search crawler
curl -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" -IL http://old.example.com/

If all three cases show a single hop with code 301 to the correct target URL and no lost parameters, the setup is correct. Also check the domain in Google Search Console: the "URL Inspection" section shows which address gets indexed after the redirect.

Was this article helpful?
← Back to Knowledge Base Ask Support