Same subdomain different domain

I am having issues as I have 2 sites. Same subdomain, but different domain.

ie:
site.domain1.com
site.domain2.com

Whenever I go to site.domain1.com it forwards to site.domain2.com

Anyone know how to fix this?

CyberPanel Subdomain Redirection Issue Solution

This is a common issue in CyberPanel where one subdomain redirects to another. The problem is typically caused by either virtual host configuration conflicts or incorrect settings in the domains’ configuration files. Let me provide you with a step-by-step solution:

1. Check Virtual Host Configurations

First, let’s examine the virtual host configuration files for both domains:

bash

# Check the configuration files in the vhost directory
cd /usr/local/lsws/conf/vhosts/
ls -la

Look for the configuration files for both of your domains (site.domain1.com and site.domain2.com).

2. Check for Redirect Rules

The most likely cause is a redirect rule in one of the domain configurations or in your .htaccess file. Here’s how to check for them:

bash

# For both domains, check for redirect rules
grep -r "Redirect" /usr/local/lsws/conf/vhosts/site.domain1.com/
grep -r "Redirect" /usr/local/lsws/conf/vhosts/site.domain2.com/

# Also check .htaccess files
cat /home/*/public_html/site.domain1.com/.htaccess
cat /home/*/public_html/site.domain2.com/.htaccess

3. Fix the Issue in CyberPanel

Method 1: Through CyberPanel UI

  1. Log in to your CyberPanel admin interface
  2. Go to “Websites” > “List Websites”
  3. Click on “site.domain1.com” (the one that’s redirecting incorrectly)
  4. Go to “Manage Aliases”
  5. Check if “site.domain2.com” is listed as an alias - if it is, remove it
  6. Go to “Manage Redirections”
  7. Check for any redirections set up for this domain and remove any incorrect ones

Method 2: Edit Configuration Files Directly

If the UI approach doesn’t work, you can edit the configuration files directly:

bash

# Edit the vhost conf file for the first domain
nano /usr/local/lsws/conf/vhosts/site.domain1.com/vhost.conf

Look for and remove any lines that contain redirect directives pointing to the other domain, such as:

  • Redirect permanent / http://site.domain2.com/
  • RewriteRule .* http://site.domain2.com/ [R=301,L]

4. Check LiteSpeed Rewrite Rules

If you’re using LiteSpeed (which CyberPanel uses by default), check for rewrite rules:

bash

# Check for rewrite rules
cat /usr/local/lsws/conf/vhosts/site.domain1.com/vhost.conf | grep -i rewrite
cat /home/*/public_html/site.domain1.com/.htaccess | grep -i rewrite

5. Review Website SSL Settings

Sometimes SSL configurations can cause redirections:

  1. Go to CyberPanel > “Websites” > “List Websites”
  2. Click on each domain and check their SSL settings
  3. Make sure both domains have proper SSL configurations

6. Restart LiteSpeed After Changes

After making any changes, restart the LiteSpeed web server:

bash

systemctl restart lsws

7. Clear Browser Cache

After making server changes, clear your browser cache to ensure you’re not seeing cached redirects:

Ctrl+Shift+Delete (in most browsers)

Additional Troubleshooting

If the issue persists, you may need to:

  1. Check if both domains are pointing to the same document root
  2. Verify DNS settings for both domains
  3. Check for server-level redirects in /usr/local/lsws/conf/httpd_config.conf
  4. Look at the website configuration in MySQL database

This should resolve your subdomain redirection issue in CyberPanel, I hope that helps.

Apparently it was the database that had the wrong URL for site name in it.