Ozy Web Design - Designing & Building Quality Business Websites

How To Redirect one website to another

This post will be short, without the extra verbal fluff associated with like articles.

2 simple ways to redirect a website:

1. Using index.html file

Simply create an index.html file in the root folder of your site and add the following content:

<!DOCTYPE html>
<html>
<head>
<title>Old Page</title>
<meta charset=”UTF-8″ />
<meta http-equiv=”refresh” content=”3; URL=https://www.destinationwebsite.com/” />
</head>
<body>
<p>This page has been moved. If you are not redirected within 3 seconds, click <a href=”https://www.destinationwebsite.com/”>here</a> to go to the https://www.destinationwebsite.com/ homepage.</p>
</body>
</html>

replace

Unfortunately, this format does not redirect subdirectories in the URL. But, the following one does.

2. Using .htaccess.

This file is created and located in the root folder of your website. Add the following content and you’re all good to go.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldwebsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldwebsite\.com$
RewriteRule ^(.*)$ "https\:\/\/www\.destinationwebsite\.com\/$1" [R=301,L]

It will redirect any URL at oldwebsite.com to https://www.destinationwebsite.com.

For example: https://oldwebsite.com.au/contact-us/ will be redirected to https://www.destinationwebsite.com/contact-us/

This method is a more powerful and more correct form of redirecting one website to another.

Note: some hosting servers don’t use “.htaccess” file. Thus, use the first method if the second method does not work for you.

I use both methods. Of course, you need to ftp to your website or access the root folder of your website through your hosting control panel.

Enjoy!

Leave a comment