Setting up a 301 or 302 redirect in cPanel

Print
  • 0

The Redirects tool in cPanel sends visitors from one address to another without editing any file yourself: a whole old domain to a new one, a removed page to its replacement, or a folder to another site. You choose the type of redirect, the source and the target, and cPanel writes the rule into the .htaccess file of the domain.

301 or 302: which one to choose

  • Permanent (301) is for addresses that will not come back: a new domain, a new page structure, a page merged into another. Search engines move the old address's position to the new one, and browsers remember the redirect.
  • Temporary (302) is for short periods when the old address will return: a maintenance page, a seasonal campaign, a test. Search engines keep the original address in their results.

In both cases the visitor sees the new address in the browser bar. If you want a second domain to show the same site under its own name, do not use a redirect: add the domain to the account instead, as shown in How to add a domain to cPanel.

Creating the redirect

  1. Log in to cPanel and, in the Domains section, open Redirects.
    The Redirects icon in the Domains section of cPanel
  2. In Type, choose Permanent (301) or Temporary (302).
  3. In the field next to https?://(www.)?, choose the domain to redirect from. The option ** All Public Domains ** applies the rule to every domain of the account, so use it with care.
  4. In the field after the slash, leave it empty to redirect the whole domain, or type the old path, for example old-prices.html or blog.
  5. In Redirects to, write the full target address, starting with https://.
  6. In www. redirection, choose how the www variant is handled. For most cases Redirect with or without www. is the right choice; the other options are Only redirect with www. and Do Not Redirect www.
  7. Tick Wild Card Redirect if the rest of the path should be kept: with it, old.md/contact goes to new.md/contact. Without it, every page of the source lands on exactly the target address.
  8. Click Add. cPanel confirms the change and the rule appears in the Current Redirects table at the bottom of the page.

Two common examples

Moving everything from an old domain to a new one

Source: old.md, path left empty. Target: https://new.md/. Type: Permanent (301). www: Redirect with or without www. Wild Card Redirect: ticked, so each page reaches its counterpart on the new domain. The old domain has to stay registered and pointed to our server for the redirect to keep working.

Sending one page to its new address

Source: your domain, path old-prices.html. Target: https://domain.md/prices/. Type: Permanent (301). Wild Card Redirect: not ticked.

Changing or removing a redirect

cPanel cannot edit an existing redirect. Find it in Current Redirects, click Delete and create it again with the new values. Deleting the redirect in cPanel also removes its rule from .htaccess.

When the redirect does not behave

  • The page loops ("too many redirects"): the target lies inside the source, for example domain.md redirected with Wild Card to domain.md/shop/, or a domain redirected to itself. For HTTP to HTTPS on the same domain, do not use Redirects: turn on Force HTTPS Redirect in the Domains section, or follow the .htaccess rules for HTTPS and www.
  • Nothing happens: the source domain must be in your cPanel account and point to our server. Also try a private window, since browsers keep old 301 redirects for a long time.
  • The redirect works only for some pages: other rules in .htaccess, a CMS or a redirect plugin may answer first. Look at the file and keep one place for redirects.
  • A security warning on the target: the target address has no valid SSL certificate. Check it under Security, then SSL/TLS Status, as shown in the AutoSSL article.
  • Error 500 after adding the redirect: the .htaccess file was already damaged or contains a rule that conflicts. Delete the redirect, repair the file, then add the redirect again.

If the redirect still fails, open a ticket and give us the source address, the target and the options you chose.

Related articles

Was this answer helpful?