#1
Setup: Ubuntu, Cyberpanel, OLS Webadmin


I have been trying to figure this out for a while, with AI no less, and still can't find a solution.

I have a WordPress multisite network with multiple second and third-level domains hosted with CyberPanel/OpenLiteSpeed. I have wildcard subdomains enabled and working for my second-level domains - *.example.com redirects to example.com properly.

However, subdomains under third-level domains like *.web1.example.com incorrectly redirect to the base domain, example.com. I need those to properly redirect to the second-level domain, web1.example.com.

Troubleshooting steps taken:
  • Added .htaccess redirect rules to preserve second-level domain
  • AI says the following Servername block entries may resolve the issue but I don't know where to add in OLS Webadmin: <virtualhost> ServerName domain1.co.com ServerAlias *.domain1.co.com </virtualhost> or ServerName domain1.co.com ServerAlias *.domain1.co.com
  • Tested behavior in incognito windows and with cached cleared
The issue persists only for third-level subdomains. Second-level wildcard redirects were fixed with:
RewriteCond %{HTTP_HOST} ^(.+\.)?(.+)\. [NC]
RewriteRule ^(.*)$ https://%2%{REQUEST_URI} [R=301,L]

But any third level wildcard is redirected to the base url co.com for example.

I have even tried specifying the specific domain redirects to their base url and it still goes to co.com, de.com, uk.com and eu.com, respectively.

Potential causes could be conflicts with the general .htaccess rule, OLS configuration missing something for overlapping wildcards, or an issue between CyberPanel and OLS.

I would greatly appreciate if support could help identify the misconfiguration leading to this incorrect redirect behavior. Please let me know any debug steps or config details needed from my side.

Thank you! Any help is much appreciated.
 
Last edited:
#2
also tried editing vhost config via Cyberpanel....still nothing.

ServerName domain1.co.com
ServerAlias *.domain1.co.com

ServerName domain2.co.com
ServerAlias *.domain2.co.com

ServerName domain3.co.com
ServerAlias *.domain3.co.com

ServerName domain4.co.com
ServerAlias *.domain4.co.com
 
#3
The third level domains are hosted in the same multisite network? And the Cyberpanel interface is quite different from the OLS interface. But if you speak about different multisite networks, you need to define access rules to route to the right instance. If the multisite instance is the same and no other wordpress installation on the same server, just direct all traffic to the same instance and Wordpress should figure it out.
 
#4
They are on the same multisite network. Yes, it should but sadly it isn't. It sends to a signup.php page. It seems Cyberpanel support is attempting to fix the issue. I'll share the results if they can tell me anything. Thank you.
 
#5
The signup.php indicates that WordPress Multisite does not recognize the DNS name. So unless you have something wrong in the htaccess that will mess up your domain name, you need to look at WordPress and double check the configuration there. I never tried third level domains, but I am serving completely different domain names in the same multisite network, so any kind of subdomain configuration is supposed to work on the WordPress side.
 
#6
Even though cyberpanel says this won't work with Openlitespeed, for the second level domains it works.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:.+)\.([^.]+\.[^.]+)$
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

It doesn't work for third levels. The only way to get third level domains to work is to use Cloudflare and to set up a page rule with a 301 redirect.

I wanted to move away from cloudflare, but it looks like I'm stuck with them until I can get this figured out. At least last time it worked. Thank you for the help...if you have any ideas, let me know. I just can't figure why it would work with Cloudflare and not with Cyberpanel/OpenLitespeed....and Wordpress otherwise.
 
#7
ChatGPT suggested to use:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:.+\.)*([^.]+\.[^.]+)$
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

So give it a try.
 
Top