Home  »  ArticlesGuides   »   Here’s How to Redirect Your Old Website to a New One

Here’s How to Redirect Your Old Website to a New One

We won’t dive into the details as to why you would redirect your old website to a new one as that is subject to a whole discussion of itself so we will just go right into the topic at hand.

Redirecting an old website to a new one brings about challenges generally related to SEO (Search Engine Optimization) and downtime but if things are done properly then there should be no downtime or SEO issues at all.

So you would want to make sure that a web address like:

https://www.oldwebsite.com/more-stuff-here/

Properly redirects to its new equivalent like so:

https://www.newwebsite.com/more-stuff-here/

The first step is you would need to set up the new domain name or website and have it configured to point to the document root of your current website or the location where the new website will be running from. This will be done at the domain level and on your webserver, the appropriate configurations will have to be done.

Redirect an Old Website to a New One in Linux with Apache

For the Apache web server, the following code will have to be placed in the .htaccess file in the document root of the old website changing the names of the websites as needed.

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

The code above will be executed by the webserver whenever there is a request to it. The code will basically ensure a request has been made to the old domain name. If that is the case then the request will be redirected to the URI but now under the new domain name.

See also  Meet Gradle the Multi-Language Build Automation Tool

It is important to perform the check for the old domain to avoid issues of double redirects which would occur without it. It is also important to note that the Apache ModRewrite module needs to be enabled. The code will perform a check and perform the redirect only if the module is active.

Using Nginx to Redirect Website

Open the nginx.conf file and add the following code to it changing the oldwebsite.com and newwebsite.com as needed:

server {
 listen 80;
 server_name oldwebsite.com;
 return 301 $scheme://newwebsite.com$request_uri;
 }

Redirect an Old Website to a New One on a Windows Server

Unless you are the server administrator then you will have to make a request to have it done for you through the “Internet Services Manager” interface. Generally, the process is simple and it uses a GUI (Graphical User Interface).

You start by accessing the “Properties” > “Home Directory” of the website you want to redirect. Next, you will need to access the “Default Web Site Properties” dialog. You will then need to Select “A redirection to a URL“. Thereafter in the “Redirect to:” field type in the new web address.

Next, select “A permanent redirection for this source” then press the Ok button for the finish.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Share it!

See also  What is RAID (Redundant Array of Independent Disks) Storage?

Available under:
Articles, Guides