Redirect IP address to Domain Name in CyberPanel

Every VPS and a dedicated server comes with a dedicated IP address. For example, In CyberPanel, when you directly put this IP address in the address bar, It returns to an error page. You can redirect your server main IP or all other IPs to the master domain or any other domain hosted on your server.

Redirect IP to Domain in CyberPanel

In this post, we will redirect IP to a domain name using CyberPanel using root level. For this, you need to open your SSH terminal using your root credentials.

Perform the following actions carefully and this setting works only for OpenLiteSpeed

After logging in root, type the following command:

 cat /usr/local/lsws/conf/httpd_config.conf

To edit httpd_config.conf file, you need to type:

nano /usr/local/lsws/conf/httpd_config.conf

After opening this, find the line:

listener Default {

Under this directive Type following line before or above “}” symbol.

map Example *

Now save this file by typing ctrl+X and Y on your pc or computer keyboard.

After this, you have to edit Example/vhost.conf file. To edit this, type the following command.

nano /usr/local/lsws/conf/vhosts/Example/vhconf.conf

There is a rewrite available in this file by default. To delete this find the following code:

rewrite  {
  enable                  1
  logLevel                9

Delete or cut this whole code by using Backspace button on your pc keyboard.

Now scroll file to the last and paste the following command in this file.

rewrite  {
  enable                  1
  logLevel                9
RewriteCond %{HTTP_USER_AGENT}  ^NameOfBadRobot
RewriteRule ^/nospider/         -   [F]

RewriteRule ^/$ [L,R=301]

In the above code replace with your domain name.

Redirect IP To Domain In Cyber Panel

Save this file.

Now restart your LiteSpeed server by typing the following command.

/usr/local/lsws/bin/lswsctrl restart

Or Reload the configuration

/usr/local/lsws/bin/lswsctrl reload

Now type your server IP in the Google address bar and hit enter. It will redirect to the domain name.

You’ve done!

When you buy through affiliate links on our site, we may earn an affiliate commission, at no cost to you.
Editor Desk
Editor Desk

I love to drive car and passionate about long drives

Register New Account
InsideHost - Your ultimate hosting partner!
Compare items
  • Total (0)