Wildcard subdomains redirecting somewhere else

sevent

Registered
Jan 3, 2010
2
0
51
Hi,

I setup a bunch of domain names while logged in as a reseller. All of the domain names have wildcard DNS entries:

* 14400 in CNAME thedomain.com.

However, anytime you visit:

whatever.thedomain.com

you are actually redirected to:

mainResellerDomain.com

instead. How do I change this behavior?

Many thanks!
 

thewebhosting

Well-Known Member
May 9, 2008
1,199
1
68
Please check virtualhost entries of domains in Apache configuration file (/usr/local/apache/conf/httpd.conf) and make sure that the document root of domains are correct.
 

sevent

Registered
Jan 3, 2010
2
0
51
The problem is with the VirtualHost entry in the Apache configuration. Make sure the ServerAlias is set as follows

ServerAlias www.thedomain.com *.thedomain.com

in the 'thedomain.com' domains VirtualHost entry and also check the DocumentRoot. BTW, have you assigned a dedicated IP for the thedomain.com domain?
Hum... this could be an issue. The only "ServerAlias" entry right now for the domains in httpd.conf is:

Code:
ServerAlias www.theDomain.com
madaboutlinux are you sure you have the right order for the ServerAlias directive in terms of the wildcard vs the main domain?

None of the sites (except the main reseller) has their own IP address. There are a very large number of them, so I can't give them all IPs. Also, this will make editing httpd.conf a pain, unless there's already some script out there for adding these entries?

Finally, do you know if there is any way to do this using .htaccess? It would be much easier for me to add something to each domain's .htaccess then to edit all the httpd.conf entries.

Thanks for your responses.
 

madaboutlinux

Well-Known Member
Jan 24, 2005
1,051
2
168
Earth
I asked about the dedicated IP for a different reason. BTW, edit the httpd.conf file and scroll down to the VirtualHost entry of "theDomain.com" and change ServerAlias to

ServerAlias www.thedomain.com *.thedomain.com
and make sure *.thedomain.com entry is not present in any other VirtualHost entry especially check the main reseller domain virtualhost entry. Once done, restart the httpd service.

And well, I haven't seen using ServerAlias in .htaccess.