Setting Up Redirects for Your Website

Print
  • 0

What a redirect does

A redirect automatically sends someone who visits one web address on to a different one. They type or click the old address, and they land on the new one without doing anything. Redirects are how you move content without breaking links, keep old bookmarks working, and make sure visitors and search engines always reach the right place.

The common jobs redirects handle: sending an old page to its new home after you have reorganised a site, pointing a whole old domain at a new one after a rebrand, and settling whether your site lives at www.yourdomain.tld or plain yourdomain.tld so it is not awkwardly reachable at both.

301 or 302: which to use

You will see redirects described as 301 or 302, and the difference matters:

  • A 301 is permanent. Use this almost always. It tells browsers and search engines the move is forever, so search engines pass the old page's ranking on to the new one. When in doubt, you want a 301.
  • A 302 is temporary. Use it only when the redirect genuinely is temporary, a holding page during maintenance, say, where you intend to send people back to the original later.

Getting this wrong mostly costs you search ranking: a temporary redirect used for a permanent move does not pass the old page's standing on, which is why the permanent 301 is the default choice.

The easy way: cPanel's Redirects tool

For straightforward redirects, whole pages or whole domains, cPanel has a built-in tool and you do not need to touch any files.

  1. Log in to cPanel at yourdomain.tld/cpanel and open Redirects, findable via the search box.
  2. Choose the type, Permanent (301) for almost all cases.
  3. Pick the domain and, if you are redirecting one specific page rather than the whole site, enter the path.
  4. Enter the destination address it should redirect to.
  5. Choose whether www and non-www versions are both redirected, the tool offers this, and both is usually what you want.
  6. Add the redirect. It takes effect straight away.

This tool is the right choice for most redirects, and because it writes the rules safely for you, it avoids the risk of editing files by hand.

Settling www versus non-www

A specific, common case worth calling out: your site can usually be reached at both www.yourdomain.tld and yourdomain.tld, and it is tidier, and better for search, to pick one and redirect the other to it. The cPanel Redirects tool handles this, point the version you do not want at the version you do, as a permanent 301. If your site runs WordPress, WordPress also has a setting for your preferred address under its general settings, which achieves the same thing. Either approach is fine, just do not set up conflicting rules in both at once.

The manual way: .htaccess

For more complex redirects, many individual old URLs going to many new ones, or patterns the cPanel tool cannot express, redirects are written in your site's .htaccess file. This is more powerful and more fiddly, and it carries the same caution as our article on forcing https: a mistake in .htaccess can take the whole site offline, so copy the existing file before editing it so you can restore it.

A single permanent redirect from one old page to a new one looks like this, added in the .htaccess file in your public_html folder:

Redirect 301 /old-page.html https://yourdomain.tld/new-page.html

Pattern-based redirects, for example sending an entire old section to a new one in one rule, use more advanced RewriteRule lines, and this is the point where it stops being a safe DIY job. If you are moving a lot of URLs, or redirecting by pattern, that is worth handing to us.

When to let us handle it

A few individual page redirects through the cPanel tool is squarely DIY. A site migration with dozens of old URLs to map to new ones, pattern-based rules, or anything that has produced a "redirect loop" error where the browser says the page redirected too many times, is where you should open a support ticket. Redirect loops in particular are almost always two rules fighting each other, and untangling them is quick for us and maddening by trial and error. Tell us the old addresses and where each should go, and we will set them up cleanly.

Good to know

The reason redirects matter beyond mere tidiness is that every link to your old pages, from other websites, from Google's results, from someone's bookmarks, keeps working instead of landing on a dead "page not found." When you reorganise a site or move to a new domain, mapping the important old addresses to their new homes with 301 redirects preserves the traffic and search ranking you have built up, which is exactly what our article on domain parking's redirect option does at the whole-domain level. Skip the redirects and that accumulated value quietly leaks away, so they are worth the few minutes they take.


Was this answer helpful?

« Back

Powered by WHMCompleteSolution