How to redirect an entire website to another website

Redirect website using the htaccess codes. Sometimes you are required to redirect an entire website to another website. Here we will discuss how you can do that by using a simple trick.

redirect website

Warning: Applying this code in the htaccess file may cause permanent redirection, until you create a new htaccess file. We strongly suggest you to create a website backup using Updraft plus. Also applying this code incorrectly may cause your website to break down. So you should apply these codes carefully to redirect website.

First log in to your cpanel to any other way by which you can access your website files.

How to redirect an entire website to another website

Now open the file manager in cpanel and go to public_html.

How to redirect an entire website to another website

Now search for .htaccess files. By default these files are hidden for security purpose and you will get no results upon searching for this file. But to show the htaccess file you will need to click on setting at the top right of file manager in cpanel.

How to redirect an entire website to another website

A new”preference” pop up box will open as shown below. Just check the show hidden files (dotfiles) and save.

How to redirect an entire website to another website

Now refresh the file manager and you will see .htaccess file. Right click on that file and select Edit.

How to redirect an entire website to another website

A popup box will. Click edit.

redirect website

Now its the time to paste the below provided code to your htaccess file. Paste this code at the top of the htaccess file as shown below.

redirect website

Here example.com is your old website and example111.com is the new website where you want to redirect your website.

Also read:  Cheapest wordpress hosting in India, users from any country can apply for this hosting plans.

or simply you are redirecting from example.com to example123.com

RewriteEngine on
 RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
 RewriteCond %{HTTP_HOST} ^www.example.com [NC]
 RewriteRule ^(.*)$ http://example123.com/$1 [L,R=301,NC]

There are other options also. If you want to show your home page to the visitor who visits 404 page in your website than you can use this code.

ErrorDocument 404 http://example.com/

If you want to use www in your site url than apply this code in your htaccess file. Just replace the example.com with your site url.

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

We hope this article will help you to redirect website using htaccess codes.If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *