How to Redirect your website to any page or external domain?

The main aim of redirect is to redirect the traffic of out website to another website. We can do this either by adding redirects in cpanel or by editing .htaccess file. We can redirect the traffic of domain.com to domain.net or else we can also add custom redirects like domain.com/index.html to domain.net/mainpage.html. You can do the following methods if the destination website is an external domain too.

Redirects in cpanel

To set redirect from cpanel login to your cpanel
1. Head to the redirects  under the Domains  section.

2. Then Click the redirects 

3. Under the Add Redirects section you can see some options,
A. Type: We can choose whether a redirects needs to be permanent(301)  or temporary(302).
B. https?://(www)?: Here we can choose the domain which we needs to forward.
C. / : If we want to forward a specific file  enter it here.
D. Redirects To: Here we enter the URl of the domain which we needed to forward the traffic to.
E. www redirection :  Here we can manage the redirect based on www like we can set the redirect to work only if there is WWW or we can make this up regardless of WWW
F. WildCard Redirect: Select if we redirect all the pages to the redirected domain.

After that click ADD.
You can  see your redirects listed under Current Redirects.

By editing .htaccess file

  1. Login to your cpanel.
  2. Go to file manager in Files section.
  3. Then go to your document root folder of the domain which you want to redirect ie from which you want to redirect traffic.
  4. There you can see a .htaccess file.
  5. Right click using the mouse and choose edit.
  6. You can add the condition of redirects here like an example given below and click on save changes on the top right corner; 
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

For the above redirect given to egwtraining.net.in  the .htacess file in the document root of the same domain will look like this.