First published in the FasterHost knowledge base. FasterHost is an Indian web host; the steps use cPanel's standard Redirects page.
A redirect sends visitors, and search engines, from an old address to a new one: a page moved, the site changed domains, or a second domain should land on the main site. With a permanent (301) redirect, search engines pass the old address's ranking to the new one. cPanel sets one up from a single form. The catch comes on WordPress sites, where a redirect you added in cPanel can do nothing at all, and the reason is the order of the rules in .htaccess.
Setting it up
- Open Redirects. In cPanel, go to Domains → Redirects.
- Choose the type. Permanent (301) for a move you will not undo: a renamed page, a new domain, two sites merged into one. Temporary (302) only when the original address will come back, such as a page taken down during a sale.
-
Choose what to redirect. Select the domain from the list, or All Public Domains for every domain on the account. In the
/box, type the rest of the old address, for exampleold-page.html. Leave it empty to redirect the whole domain. -
Enter the destination and the options. In Redirects to, type the full new address including
https://; cPanel requires the protocol. Under www. redirection, Redirect with or without www. suits almost every site. When you move a whole domain, tick Wild Card Redirect: it sends each page to the same path on the new domain, soold.in/aboutlands onnew.in/aboutrather than on the home page. - Add it and test it. Click Add, then open the old address in a private browser window. To see exactly what the server answers:
curl -I https://example.in/old-page.html
You should see a 301 status and a Location header with the new address.
One quirk: a redirect cannot be edited in place. To change one, delete it from the list and add it again.
Redirects that do nothing on WordPress
You add the redirect, test the old URL, and get WordPress's own page instead, often a 404. The redirect is there; it just never runs.
cPanel writes its redirect rules at the bottom of the site's .htaccess file, below WordPress's own rules. WordPress's block (its standard .htaccess) ends by handing every address that isn't a real file or folder, which on WordPress means every post and page, to index.php. So WordPress catches the request first and the rules underneath never get a turn. A current WordPress install writes the block like this (its comment lines left out):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# ...the redirect lines cPanel added end up down here
The fix: open .htaccess in File Manager (switch on hidden files in its Settings; this File Manager guide shows where) and move the lines cPanel added, the ones naming your old address, above the line # BEGIN WordPress. Then run the curl -I check again.
If you have many redirects, manage them inside WordPress instead, with a plugin such as Redirection. That avoids editing .htaccess by hand.
Moving a whole site to a new domain
- Redirect every page to its equivalent with a wildcard 301, not everything to the home page.
- Keep the old domain registered and redirecting for at least a year; Google's advice is to keep redirects for as long as you can.
- Tell Google with the Change of Address tool in Search Console, and update your own internal links to the new domain.
- HTTP to HTTPS is a different job, and not one for the Redirects page: switch on Force HTTPS Redirect for the domain under Domains. It covers every page of the domain at once.
Quick answers
301 or 302? 301 for anything permanent: a moved page, a new domain, a merged site. Search engines then index the new address in place of the old one. Use 302 only when the original address will come back.
How do I redirect a whole domain to another domain? In Domains → Redirects: Permanent (301), select the old domain, leave the path empty, enter the new domain with https://, choose Redirect with or without www. and tick Wild Card Redirect so each page goes to the same path on the new domain.
How do I edit a redirect? You can't change one in place. Delete it from the list and add it again with the new values.
Top comments (0)