A redirect sends anyone who asks for one address to a different one. Use a 301 redirect when a page or a whole site has moved for good, and a temporary redirect when it has not. This article explains the difference, when you need one, and how to set one up on cPanel hosting.
When you need a redirect
Google's guide to redirects and Google Search lists the common reasons:
- You moved your site to a new domain.
- The same page can be reached at several URLs, and you want to choose one.
- You merged two websites.
- You removed a page and want visitors to land somewhere useful instead of an error. See website errors explained for what they see without one.
Permanent or temporary
The type of redirect tells Google what you intend.
| Type | Status codes | What Google does |
|---|---|---|
| Permanent | 301 and 308 | Follows it, and uses it as a signal that the new address should be the canonical (main) one |
| Temporary | 302, 303 and 307 | Follows it, but does not treat the new address as canonical, so the old page may still appear in results |
Google says to use a permanent redirect only when you will not change it back. If the change is short, for example a service that is briefly unavailable, use a temporary one so the original address stays in search results.
Which method to use
Google ranks the methods by how reliably it understands them, with server-side redirects first. Google says a server-side 301 or 308 is the best way to make sure search engines and visitors go to the right page. Other methods exist:
- Server-side redirect (best). Set in your web server or in code. Google gives examples for PHP, Apache and NGINX. In PHP, the redirect header must be sent before any other output.
- Meta refresh or HTTP refresh. Use these only if a server-side redirect is not possible. A refresh at 0 seconds is treated as permanent; one with a delay is treated as temporary.
- JavaScript redirect. A last resort. Google has to render the page first, and rendering can fail, so it might never see the redirect.
How to set up a redirect in cPanel
cPanel's own documentation for the Redirects feature describes it. The main points:
- Choose Permanent (301) or Temporary (302). The documentation says a 301 prompts search engines to update their records, while a 302, meant for things like maintenance, has no effect on them.
- Pick the domain and the path to redirect from, and enter the full destination, including
http://orhttps://. - The www options let you redirect only visitors who type
www, all visitors, or neither. - You cannot edit a redirect once it exists. Delete it and make a new one.
- To force every visitor onto HTTPS, use the Force HTTPS Redirect option in cPanel's Domains area, not this tool.
- Use the link in the Current Redirects table to test it. Browsers cache redirects, so you may need to clear your cache to see a change. Our guide to clearing your browser and DNS cache shows how.
A host can switch this feature off, so if you cannot find it, ask your host.
Watch out for WordPress
cPanel's documentation notes that redirect rules sit at the bottom of the .htaccess file, so some applications, such as WordPress, may ignore them. In that case it recommends configuring the redirect by hand. If you are not comfortable editing .htaccess, ask our support team before you change it, and take a backup first. Our article on why backups matter explains how often.
Good habits
These are suggestions rather than rules from Google:
- Send each old address straight to its final destination, not through a chain of several redirects.
- Redirect to the most relevant page, not always the homepage.
- Update your own internal links and your sitemap to the new address. See sitemaps and robots.txt.
- Test the old addresses after the change, on a phone and a computer.
Google's page does not say how long to keep a redirect in place, so keep it for as long as people or other sites may still use the old address.
FAQ
Is a 301 the same as a 308?
Google lists both as permanent redirects. For a small site, a 301 is the usual choice and is what cPanel's Redirects tool creates for a permanent move.
Will a 301 redirect hurt my search ranking?
Google's page describes a permanent redirect as a signal that the new address should be canonical. It does not promise anything about rankings, and it notes that old URLs may keep appearing for a while after a domain move.
Can I redirect a whole domain to another?
Yes. Redirects are used for site moves to a new domain. Plan it, redirect page to page where you can, and check the result in Search Console.
