As a blogger who manages many blogs at a time, You have to deal with many challenges that you might not have experience with. And many of these tasks are done at the server level which means you need some kind of help to complete the task.
One of such tasks is redirecting one domain to another. For example, Let’s say your website is currently accessible on abc.com and you have updated your website’s domain to abc.io. And you want to redirect all the requests coming on abc.com to abc.io. We get too many requests for this task, so we decided to create a tutorial that anyone can follow to complete this task successfully.
So, Let’s get started with the actual tutorial. Considering you have two websites on a single server hosted by ServerAvatar, Here are the steps you have to follow.
Connect with your Server via Filezilla
Filezilla is a Free FTP solution. You can use Filezilla to perform all the tasks that you can execute on FTP/SFTP protocol, SFTP stands for Secure File Transfer Protocol. So, Once you have downloaded and installed FileZilla, Open it and you will see a screen just like the following image.
The first row of the Filezilla has all the quick action buttons that you can do to perform various tasks like getting disconnected from the server, searching for the files recursively and much more.
The second row of the Filezilla is for the logs, When you perform some task like renaming or moving a file from one directory to another, You will see if the task was performed successfully or not in that section.
The third section has two more sub-sections, The one on the left hand side is for your local machine. It means that it will show files stored on your local machine. On the right hand side, You can see the files hosted on the server you are connected.
And the fourth section will show you pending tasks as well as tasks that are being executed. So, now you understand Filezilla, It’s time to connect with your server. Whenever an application is created on ServerAvatar, the SFTP user is created too! You can access the SFTP user information on Application dashboard so that you can connect with your Server via FTP. On application dashboard, You will find SFTP information just like the following image.
Use this information in FileZilla to connect with your Server. Once you are connected, You are ready to move on to the next step.
Upload the Configuration File to Redirect
Configuration files are just like htaccess file. You can write any Apache/Nginx rule you want in that configuration file and upload it to make the changes to your site. In this case, we have to create a configuration file to redirect from one domain name to another.
The template configuration file for the redirection from one domain to another looks like the following. Replace your domain names and you are ready to go. Also, note that these rules are for Apache, you have to convert the rules in Nginx format if you want to redirect your domain on Nginx.
<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^(.*)$ http://destination.com/$1 [R=301,L] </IfModule>
Create a file with .conf extension with the above given content. Do not forget to replace the destination domain name. Once you have created and saved the file in your local computer, Open the Filezilla and open the directory with name same as the name of your application.
In that directory, you will find a directory called apache or nginx based on your Server Stack. In this case, we are using Apache, It means that we have to go into the apache directory.
Once you are in, upload your configuration file by selecting the configuration file from the left side of the 3rd section in your FileZilla, Just like the following image.
Once you have uploaded the file, You have to restart the Apache service to apply the changes. Make sure that your file is correct and has no syntax errors.
Restart the web server
In this step, we don’t have to actually restart the whole machine. We just have to restart a service responsible for handling the web requests, For example, Apache or Nginx. In this case, we have Apache, so, we will restart Apache.
Open the Server Panel of the server hosting this redirection file. On the left hand side of the screen, you will see a section called Services just like the following image.
Click on the services and you will get list of services that are running on the server. Just like the following image.
Click on the Restart button given on the service. In this case, we want to restart Apache. If you are not using Apache, You have to restart Nginx.
Once the service is restarted, the new settings will be applied immediately. Now, Your domain should redirect to another domain name we specified in the configuration file.
So, this is how you can redirect from one domain to another using ServerAvatar. Let us know if you are facing any issue following this tutorial, we will respond as soon as possible.