Website Redirects

There can be many situations where you may wish to transfer your website traffic to a different domain, either permanently or temporarily. You may wish to redirect your site while you preform maintenance on your website. Or perhaps you need to redirect a subfolder of your site to another website, such as a blog or shop. This can all be achieved with at website redirect.

There are many ways to preform this action. Here are a few of the best methods

The cPanel Redirect App

The easiest method of installing a website redirect is using the Redirects app found in your cPanel. But first, you will need to log into your cPanel. You can find a guide on how to access your cPanel here.

cPanel Domains section

Once you are logged into your cPanel, scroll down to the Domains section and open the Redirects app.

cPanel Redirects

Add Redirect

In this section, you can add a new redirect for any of your current domains.

cPanel Redirects - Add Redirect

Enter in your information here for your redirect.

First choose whether the redirect is permanent or temporary. Do not worry too much about the term “permanent”, you can always change it later. The term “permanent” only means that some browsers will update any bookmarks to that domain.

Next, choose your domain from the drop down. You can choose any domain, addon domain or subdomain set up in your cPanel.

Now you can choose what subfolder you will to trigger the redirect. If you want to redirect the entire domain, leave this field blank.

Lastly, enter the target of the redirect. Be sure to include the “https://” with the domain name.

Once you have all of your information entered correctly, click the Add button to create your website redirect.

Type

  • select whether the redirect is intended to be permanent or temporary
  • Permanent (301)
    • A permanent redirect will notify the visitor’s browser to update any bookmarks that are linked to the page that is being redirected.
  • Temporary (302)
    • Temporary redirects will not update the visitor’s bookmarks.

https?://(www.)?

  • Choose any of your domains or subdomains that you are looking to redirect from the drop down menu

/

  • Enter the path to the directory that you wish to redirect.
  • If redirecting the whole domain, leave this field blank.

Redirect to

  • The target URL for the redirect
  • You will need to enter the “https://”

www. redirection

  • Set whether you wish to redirect both the www. and blank domain names
    • Example: www.example.com and example.com

Wildcard Redirection

  • Selecting this option will redirect all files within a directory to the same filename in the redirected directory.
  • You cannot use a Wild Card Redirect to redirect your main domain to a different directory on your site.

Current Redirects

In this section, you can see all of your currently set redirects. Unfortunately, it is not possible to edit redirects once they are set up. The only options here is to delete the redirect and create a new one.

  • the domain name associated with the redirect
  • this is the directory that is set to redirect
  • a “/” indicates the entire directory
  • clicking on the link here will take you to the site
  • the system will redirect any URL that matches the regular expression in this column
  • this is typically left blank
  • the target URL for the redirect
  • 301 denotes a Permanent redirect
  • 302 denotes a Temporary redirect
  • shows redirect status
  • either Permanent or Temporary
  • also redirected
  • if the redirect is a Wildcard redirect, it will be checked here
  • allows you to delete the redirect

The .htaccess File Redirect

The other common method of installing a website redirect is by using the .htaccess file in your document root. You can find more information on .htaccess files here.

You can create or edit your .htaccess file from your cPanel File Manager. If you are not sure how to access your File Manager, check out this guide first.

Once you are in your File Manager, navigate to the document root of your domain. This is the folder that your website files are stored. If the domain you are looking to redirect is the primary domain, it will be the /public_html folder. An addon domain or subdomain will typically be in either the /[domain name] folder or the /public_html/[domain name] folder (replace [domain name] with the addon domain or subdomain). If you cannot find the document root folders, check out these guides for addon domains and subdomains.

Now that you are in your document root folder, look for the .htaccess file. If you cannot find your .htaccess file, it is possible that it is hidden. Click on the Settings option in the upper right-hand side of the file manager menu bar. You should now check the box for Show Hidden Files (dotfiles). If you still do not see the .htaccess file, you will need to create one. Click on the +File button in the upper left-hand side and enter the name of the file as “.htaccess”. Be sure to include the preceding period (“.”).

Now that you have your .htaccess file, you will need to edit it. Right click on the file and choose Edit from the menu.

The File Editor

Once you open your file editor, you may see that there is some coding in the file already. In this example, this coding is related the the MultiPHP Manager. You should leave code in this file, unless you are certain that it can be removed. If you are adding a redirect to your domain, it should be at the top of the .htaccess file.

cPanel File Editor

The format of the Redirect command is as follows:

Redirect [Type] [Location to Redirect] [Target of Redirect]

Type

  • 301 – permanent redirect
  • 302 – temporary redirect

Location to redirect

  • what directory or file you wish to redirect.
  • if you are redirecting your entire site, use “/”

Target of Redirect

  • the target directory of your redirect
  • must include “https://”

Here is a few examples of how to create an .htaccess redirect. In any of these examples, you can substitute 301 for 302.

One you have your file updated, click on the Save Changes button to save the file. You should now test the redirect in your browser to test the redirect. It should be active instantly, however, you many need to clear your browser cache if the redirect does not happen .

Congratulations, you are a coder now!

Common .htaccess Redirects

Here are a few examples of commonly used .htaccess file redirects. These can be used to redirect your entire domain, or only portions of it.

Remember to replace example.com with your target domain name.

Redirect 301 / https://www.example.com/

This example will redirect all traffic to your domain to example.com.

Redirect 301 / https://www.example.com/subfolder/

In this example, all of your website traffic will be redirected to a subfolder of example.com.

Redirect 301 /subfolder https://www.example.com/

For this example, any traffic sent to the subfolder of your domain is redirected to the home of example.com.

Redirect 301 /subfolder https://www.example.com/subfolder

For this example, any traffic sent to the subfolder of your domain is redirected to the subfolder of example.com.

Redirect 301 /pagename.php https://www.example.com/pagename.html

For this example, only traffic to the page pagename.php is redirected to the described page on example.com.

If you are still having issues, and need further support, please reach out to our support team using any of these methods.

Recent Articles

What is Cloud Hosting

You probably have heard a lot of buzz around the internet about "the cloud". But what is the cloud that everyone is so excited about, and what does it have to do with your [...]