Skip to content

If you ever get a new domain, and you want to redirect all the traffic going from the old domain to your new domain, you can do this simple .htaccess trick.

Log into your cPanel, and into file manager.  Go into your public_html folder.  You should see the file .htacess.  If you do not, then it may be hidden.  On the top right-hand corner is the settings button.  Click on that to show hidden files.  If it still does not show up, then you can just create a new file and call it .htacess  (that is dot in front of htaccess)

Open up that file and add the text below

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/ [R=301,L]

If you want all the traffic to go to a certain page or URL use the code below

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/folder/ [R=301,L]

Be sure to change the text in Red to your domain and URLS you want to use

First, before even getting your site to load up as https, you need to have a SSL certificate installed on your website.  A quick way to do that if you web host allows is using Let's Encrypt.  That can be installed in your cPanel.  Check out WPKbase.com on how to install Let's Encrypt.

If you are using WordPress, you can easily do it in Settings >> General, and changing the http to https in the two sections

How to set SSl in WordPress
How to set SSl in WordPress

 

If you are using something else, or HTML based site, then log into your cPanel, click on file manager and look for .htaccess file.  If you ca not see it, you may need to show hidden files.  If you still do not see it, then you can create a new file and call it ".htaccess".  No quotes and yes a "." period is the first character.  Open the file up and paste the following

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

Change the example.com to your domain you want to use.  Then save file.

type in your domain in the address bar of your browser and it will now load up using https://.  If it fails clear your browser cache files or try another browser.