Knowledgebase

Back to Tools and Features

How To Create A Redirect For My Site


This article contains information about redirecting your site.

Step 1: Add The Following Rules To Your .htaccess File Located In Your public_html Folder.

This rule will redirect all none SSL traffic to the SSL (HTTPS) portion of your site
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^ https://yourdomain.com%{REQUEST_URI} [NS, R, L]
In addition, Use one of the following rules, www.yourdomain.com is different from yourdomain.com.
You will need to redirect all traffic from one to another.
If your SSL is for www.yourdomain.com you will want to use the first rule to redirect all yourdomain.com traffic to www.yourdomain.com
This rule will direct all traffic to yourdomain.com to www.yourdomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com$
RewriteCond %{REQUEST_URI} !^.*www.*$
RewriteRule ^(.*)$ http://www.yourdomain.com [R=301]
If your SSL is for yourdomain.com you will want to use the first rule to redirect all www.yourdomain.com traffic to yourdomain.com
This rule will direct all traffic to www.yourdomain.com to yourdomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
RewriteRule ^(.*)$ http://yourdomain.com [R=301]

 

 

 

 

 

 

 

 

 

*replace yourdomain.com with the domain you need to redirect to.
For more information on rewriting rules, you can go to Apache.org

A video on creating redirects on cPanel can be found here. Note that some applications like WordPress will use redirects already in your .htaccess file to function. Because of this, you may need to edit your .htaccess file and move the redirects cPanel creates above the ones already in your .htaccess file.


Related Articles

How To Create And Download A Backup
How To Delete Your Content
Can I Add My Own CGI Scripts
Do I Use Localhost or RemoteMYSQLhost For A MYSQL connection
How To Backup My Site

Can’t Find what you need?

No worries, Our experts are here to help.