Addresses change. You move to a new domain, rename a page, drop the www, or switch the whole site to HTTPS. A redirect tells browsers and search engines where the content went, so visitors don't hit a dead end and Google carries your rankings over to the new address.
This guide shows how to create redirects in cPanel's Redirects tool, when to write .htaccess rules by hand instead, and how to test the result and fix the dreaded "too many redirects" error.
301, 302 and the rest
A redirect is an HTTP status code plus a Location header with the new address. The code tells the client how permanent the move is.
| Code | Meaning | Use it for |
|---|---|---|
| 301 | Moved permanently | New domain, renamed pages, www/non-www, HTTP to HTTPS |
| 302 | Found (temporary) | Maintenance pages, short campaigns, A/B tests |
| 307 | Temporary, keeps the request method | APIs and form posts (needs .htaccess) |
| 308 | Permanent, keeps the request method | APIs and form posts (needs .htaccess) |
For almost every website task, 301 is right. Search engines treat it as a signal to replace the old URL with the new one in their index.
Warning: Browsers remember 301 redirects. If you create one by mistake, visitors who already followed it may keep being sent to the wrong place even after you delete it. Test new redirects in a private window before you rely on them.
Create a redirect with the Redirects tool
- In cPanel, open Domains › Redirects, or type "redirects" in the search bar.
- Choose the Type: Permanent (301) or Temporary (302).
- In the domain drop-down, pick the domain the visitor arrives on, or All Public Domains.
- In the path field after the slash, enter the old path, for example
old-page.html. Leave it empty to redirect the whole domain. - In Redirects to, enter the full destination including the scheme:
https://www.example.com/new-page/. - Choose a www. redirection option (see below).
- Tick Wild Card Redirect if every path should map to the same path on the new domain.
- Click Add.
Your redirect now appears under Current Redirects, where you can Remove it again. Exact labels vary slightly between cPanel versions, but the fields are the same.
The www. redirection options
- Only redirect with www. — only
www.example.comis redirected. - Redirect with or without www. — both forms are redirected. This is what you want in most cases.
- Do Not Redirect www. — only the bare domain is redirected.
What Wild Card Redirect does
With Wild Card Redirect on, old.example/blog/post-1 goes to new.example/blog/post-1. With it off, every request on the old domain lands on the single destination you typed, usually the homepage. When you move a whole site, switch it on. When you redirect one page, leave it off.
Common redirect tasks
Move a site to a new domain. First add the new domain and get the site running there; our guide on adding a domain in cPanel covers that. Then create a 301 on the old domain, with an empty path, Redirect with or without www. and Wild Card Redirect on. Keep the old domain registered — if it lapses, someone else can buy it and capture your traffic.
Redirect a single page. Enter the old path, set the full new URL as the destination and leave Wild Card Redirect off.
Force HTTPS. Don't use the Redirects tool for this. Go to Domains › Domains and switch on Force HTTPS Redirect for the domain. It requires a valid certificate first; see our SSL and HTTPS guide. Use one HTTPS method only, not this toggle and an .htaccess rule and a plugin.
Where cPanel stores redirects
The Redirects tool writes Apache rewrite rules into the .htaccess file in the domain's document root. You can see them in File Manager once Show Hidden Files (dotfiles) is enabled under Settings; our File Manager guide shows where that switch is.
Order matters in .htaccess. Apache works through the rules from the top, and a WordPress block placed above your redirect can handle the request first. Always download a copy of the file before you edit it.
Write redirects in .htaccess yourself
For more control, write the rules directly. Put them at the top of .htaccess, above any # BEGIN WordPress block.
A single page with mod_alias:
Redirect 301 /old-page.html https://www.example.com/new-page/
Note that Redirect matches prefixes, so /old would also catch /old-news. Use RedirectMatch with an anchored pattern when you need an exact match:
RedirectMatch 301 ^/old/?$ https://www.example.com/new/
Remove www from every address:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
Move an old domain to a new one and keep the path:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.new-domain.com/$1 [R=301,L]
The full syntax is documented in the Apache mod_rewrite reference. A typo here gives a 500 error for the whole site, so if that happens, restore your copy and follow our guide to fixing a 500 Internal Server Error.
Test your redirects with curl
A browser hides what happens between the first request and the final page. curl shows each step:
curl -I http://example.com/old-page.html
curl -sIL http://example.com/old-page.html | grep -iE "^(HTTP|location)"
The first command shows only the first response. The second follows the whole chain. A clean result is one redirect followed by 200:
HTTP/1.1 301 Moved Permanently
location: https://www.example.com/new-page/
HTTP/2 200
If you see three or four hops, for example HTTP to HTTPS, then to www, then to the new path, combine the rules so the visitor goes straight to the final address. If the same addresses repeat, you have a loop.
Fix redirect loops
"Too many redirects" (ERR_TOO_MANY_REDIRECTS) means two rules are sending the visitor back and forth. The usual causes:
- Several layers doing the same job. Force HTTPS Redirect, a hand-written
.htaccessrule and a security or SEO plugin all redirecting to HTTPS. - WordPress addresses don't match. Settings › General says
http://or the bare domain while the server forceshttps://www.. - A proxy in front of the site. A CDN set to send plain HTTP to the server while the server forces HTTPS creates an endless loop.
Work through it methodically: trace the chain with curl -sIL, switch off one layer at a time and keep exactly one method for each job. In WordPress you can pin the addresses in wp-config.php:
define( 'WP_HOME', 'https://www.example.com' );
define( 'WP_SITEURL', 'https://www.example.com' );
Clear any page cache afterwards so stale redirects aren't served from cache.
Troubleshooting checklist
| Problem | Likely cause |
|---|---|
| Old page still shows | Browser cache, or a rule above yours catches the request |
| Every old URL lands on the homepage | Wild Card Redirect is off |
| 500 error after adding a rule | Syntax error in .htaccess |
| Certificate warning on the old domain | The old domain needs its own certificate before it can redirect HTTPS traffic |
After a domain move, watch the coverage reports in Google Search Console for a few weeks. Our guide to getting indexed by Google explains what to look for, and the guide to moving WordPress covers the rest of a migration.
In short
- Use Domains › Redirects with Permanent (301) for lasting changes.
- Turn on Wild Card Redirect when moving a whole domain, and leave it off for single pages.
- Force HTTPS with the toggle under Domains, and use only one method.
- Write
.htaccessrules above WordPress's block, and keep a backup. - Test with
curl -sIL: one hop, then200.
Redirects on Hostigan hosting
Hostigan web hosting comes with cPanel, so you can create redirects, force HTTPS and edit .htaccess yourself when you move a domain. If a redirect still refuses to behave, contact our support.
Frequently asked questions
Use 301 when the move is permanent, such as a new domain or a renamed page; search engines then transfer the old address's ranking to the new one. Use 302 only for temporary detours like a maintenance page or a short campaign.