Subserver web traffic going to parent's folder???

I have set up “parentdomain.com” on my server. I have also set up a subserver called “sub.parentdomain.com”.

DNS is resolving ok for both. However, when I enter http://sub.parentdomain.com in a browser, I do not see the files that are in

/home/parentdomain/domains/sub,parentdomain.com/public_html/

but rather the files in:

/home/parentdomain/public_html/

My browser address bar still reads “sub.parentdomain.com” though. Its as if the name-based forwarding in Apache is not working properly in this case.

Any ideas???
-Jason

This may or not be worth mentioning - but I just saw that the https version of sub.parentdomain.com DOES point to the correct web folder…

A wild guess… Since you’re saying you have SSL set up for both the parent and sub server, do you have separate IP addresses assigned to them? If so, you might want to check if the Apache config is correct in terms of IP addresses.

Another hunch would have to do with what exactly the (sub-)domain name is. Virtualmin “reserves” a few subdomains for its own use, like “webmail.example.com”, and trying to create a subserver with that name leads to serious confusion. :slight_smile:

I have a top level virtual server example.com
Everything works fine for that domain.

I have a virtual sub-server on the same account
example2.com - Note it is not a subdomain

If I don’t have any files in example2.com’s public_html folder, references to http://example2.com/ return the index file for example.com THat’s pretty strange.

If I put a file hello.html in example2.com’s public_html folder then http://example2.com/hello.html is returned ok. But http://example2.com/ still returns example.com index file.

As long as I have an index.html (or index.php) in example2.com’s public_html folder I’m ok. It shouldn’t be required but I can live with that.

Now I have a further problem. In example.com I renamed a few pages and added rules in .htaccess to redirect old links to the new pages.
So I have, for example
Redirect permanent /contact/ http://example.com/contact-us/
in the .htaccess file in example.com’s public_html folder

That works fine: http://example.com/contact/ is redirected to http://example.com/contact-us/

But references to http://example2.com/contact/ are also redirected to http://example.com/contact-us/
and worse
http://example2.com/contact/some-other-name are redirected to http://example.com/contact-us/some-other-name

In this case the log files for example.com have entries for this request, and those for example2.com do not.

What is going on? Why is Apache even referencing .htaccess in the documentroot of example.com for requests with the domain example2.com.

I am very well versed in running servers, I worked with apache since 1.1 days. I can see no reason for this happening. The virtualhosts files for both domains are perfectly fine. I can’t find a debug option for apache which will show me how it is processing .htaccess files. Plus this is a production server so I don’t want to turn too much debugging on if I can help it.

Any help will be appreciated.

Edit: If I remove the .htaccess rules from example.com, it still happens, even after restarting apache. In fact in the small hours I restarted the server after an OS update and it still happens.

A rather complex thing… I fear my “by-heart” knowledge of Apache and how it chooses domains to serve is not sufficient to venture a guess here without seeing the configuration files for myself… I.e. I’d need access to the system in question and test stuff out. Wouldn’t want to mess with your production server though.

So at this point, the best advice I can give would be to check out the Apache documentation. It has an extensive chapter about choice of virtual domains (see below), and likewise about .htaccess files and redirects (for which there are multiple ways to implement them).

http://httpd.apache.org/docs/2.2/en/vhosts/details.html