Setup Permanent 301 Domain Redirection in OpenLiteSpeed Server

WebHostingSetup Permanent 301 Domain Redirection in OpenLiteSpeed Server

In this article, you will find instructions for creating a server-side 301 URL redirection on an OpenLiteSpeed webserver. If you have changed your domain name or want to switch it to a new one and would like to retain all previous URLs and backlinks, then you can do this by following the method explained here. This will cause every user who visits one of the old URLs to be immediately redirected to the new domain’s version of that URL. In this tutorial, I will walk you through the steps of setting up a URL Redirection on your OpenLiteSpeed web server, which automatically removes the old domain name from the URL and places the new domain name, while keeping the rest of the slug the same.

A 301 redirect is a server-side response that is used to tell search engine crawlers such as Google and Bing that the content on an old URL has been moved to a new URL.

Usually, in the Apache web server or in your cPanel setup, you simply edit the .htaccess file in the root directory to set up such domain redirection. But, in the case of the OpenLiteSpeed server, the steps are different because the .htaccess file is ignored here and does not implement such redirection through it.

What does this redirection do?

Suppose you own a website called abc.com, and you have published several pages and articles on this website. You now need to change the domain name to xyz.com for a variety of reasons, such as a change in your company name or a modification to your business procedure.

In such cases, you would like to preserve all your previous pages and blog articles, and their links, including images and other content. When a user types abc.com in their browser, you would want him to automatically redirect to the new domain xyz.com. Not only that, all the links pointing to the different pages on your previous domain should still bring visitors to the same page but to the new domain. So when they click or try to open https://abc.com/blog-post-name/, they automatically redirect and reach https://xyz.com/blog-post-name/.

How to do it?

This article is for those who have their old website hosted on the openLiteSpeed web server. So, here are the steps for setting up this server-side 301 domain redirection.

    1. Login to your OpenLiteSpeed webserver Admin panel. You can access it by typing the server IP with port 7080. Make sure you use it with HTTPS in the URL, because the HTTP does not work. 
      https://server-ip:7080
    2. When you try to access the above URL, your browser may show an error related to an invalid self-signed SSL certificate, do not worry and simply click the advanced option and continue to the website, or accept the risk and continue. You also need to make sure that, port 7080 is already open on your server.

      Self-Signed SSL Warning
      Self-Signed SSL Warning
    3. Now login to the admin panel with the Admin username and password, that your server would have provided you with while set up.

      Server Admin panel Login
      Server Admin panel Login
    4. Once you are logged in, click on the Virtual Hosts menu on the left sidebar. This will list all the virtual hosts’ names on the right pane. In the case of multiple domain hosting, the virtual host for the first domain that you hosted may show on top and have a name called default or WordPress depending upon your setup. You can also verify and find the correct virtual host by looking at the Virtual Host Root path, which actually is the website’s root directory.Finding Virtual Host Name
    5. Now that you have confirmed your virtual host, you can click on that small action button next to the virtual hostname to open its editing panel.
    6. Next, click on the Rewrite Tab on top and then click the edit icon for the Rewrite Rules (See screenshot below).

      Add Rewrite Rules
      Adding Rewrite Rules
    7. Paste the following rewrite rule after replacing the new domain name. So at this place, you will put the new domain where you want this old website to be redirected to.
      RewriteRule ^(.*)$ https://xyz.com/$1 [L,R=301,NC]
    8. Click save and then restart the OpenLiteSpeed server for the changes to take effect.

      Save the rewrite Rule and Restart the Server
      Save the rewrite Rule and Restart the Server

Now I’ve shown you how to setup a permanent 301 URL redirect from one domain to another. This is a simple process and can be done in just a few minutes. Now that you know how it works, go ahead and try it yourself!

I hope you enjoyed reading this article and this helped you set up redirection. In case you still have issues or need help from a professional in this regard, you can contact us through skype live:hawkdivetech.

Nasir Sohail
Nasir Sohail
Nasir is a software engineer with an M.Sc. degree in software engineering and various certifications related to computer hardware and networking, such as MCSE, CCNA, RHCE. He has more than 15 years of mixed industry experience mostly related to IT Support, Web development and Server administration. He also offers his freelancing gig for IT support and consultancy and has more than 400 combined five-star reviews across platforms like Fiverr, Google, TrustPilot, etc.
Watch & Subscribe Our YouTube Channel
YouTube Subscribe Button

Latest From Hawkdive

You May like these Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.