Custom HTTPD configuration improvement

ostendo

Verified User
Joined
Dec 6, 2006
Messages
64
Hi all,

I'd like to be able to enter custom HTTPD configuration on a per-subdomain-base. So if I have www.domain.com and sub1.domain.com and sub2.domain.com and I want some dangerous php-configuration for sub2.domain.com, I'd like to be able to do that without bothering about the security for www.domain.com (or sub1.domain.com)

Is that possible?
 
This is by the way in the following specific example pretty useful (and I'm in need for a solution to this example..!)

domain.com has a website using TYPO3 (www.typo3.com) and it's RealURL-extension. If you have no idea what that means, no problem.
For this combination it is necessary that the following is put into a .htaccess-file or into the httpd.conf for that specific domain:

Code:
RewriteEngine On
RewriteRule ^(typo3|typo3temp|typo3conf|t3lib|fileadmin|uploads|phpmyadmin|phpMyAdmin|horde)(/.*)?$ - [L]
RewriteRule ^(.*)$ /index.php [L,E=ORIG_SCRIPT_NAME:/index.php]

That is inside my /home/user/domains/domain.com/public_html/.htaccess file.

This does, in principle, the following: it redirects every single request to a file somewhere inside this folder (or many more levels deep) to /index.php.

Now I create a subdomain: sub.domain.com. This is located in /home/user/domains/domain.com/public_html/sub/ and every request to a page in sub.domain.com/ will request a page from this folder. Apache, smart-ass as it is, searches for a .htaccess-file within the rootline and finds one, one folder above the current one (the one with the redirects).
So Apache redirects every request to sub.domain.com/abcd/ef to sub.domain.com/index.php

And that's not what I want.

Only two possible solutions to this problem:
a) place the subdomains NOT in a subfolder of the main domain (so, for example, use /home/user/domains/domain.com/subdomains/sub/public_html), which would solve me a lot of trouble, but is probably impossible to work out (..?)
b) place the code in the .htaccess in the httpd.conf for the domain. Only problem is then that all the custom httpd configuration is also copied to the subdomains, and I don't want it at the subdomains.


I hope this (maybe technical) story sounds a little bit logical.
 
Last edited:
A subdomain doesn't get it's own section of the user's httpd.conf file. You can of course create the subdomain as if it were a main domain.

Jeff
 
A subdomain doesn't get it's own section of the user's httpd.conf file. You can of course create the subdomain as if it were a main domain.

Jeff

ofcourse it gets it own section.. you have to add a VirtualHost directive per subdomain.

To create the subdomain as if it were a main domain gives DNS trouble. Ofcourse it's possible, but not as easy as 1-2-3.
 
My error; I wasn't thinking this out thoroughly.

Why do you get DNS trouble? I don't when I create subdomains as their own domain.

Jeff
 
My error; I wasn't thinking this out thoroughly.

Why do you get DNS trouble? I don't when I create subdomains as their own domain.

Jeff

well, you get a new DNS zone sub.domain.com, but instead, you want an A-record on domain.com directing sub to your IP.

Ofcourse it's all not that difficult to figure out, but it's not default behaviour in DA to do it right..

Would it be a problem to put subdomains in a folder like:
/home/user/domains/domain.com/subdomains/sub/public_html/
?

(and of course implementing that into DA...)
 
well, you get a new DNS zone sub.domain.com, but instead, you want an A-record on domain.com directing sub to your IP.
DirectAdmin creates a new zone. That zone contains among other records, an A record pointing the subdomain to the main domain's IP#. Is your problem with the extra records? I don't see why that's a problem but if it is you can always delete the extra records. Is your problem that you get a whole zone? If so, why is that a problem? You can always delete the entire zone and create the A record.
Ofcourse it's all not that difficult to figure out, but it's not default behaviour in DA to do it right..
I'm not sure what right means in the context of the DNS. Personally, well I would probably have done it the way you suggest, with an extra A record, but others would probably want a whole new zone with NS delegation in the parent domain's zone. I don't know if any is more right than any other.
Would it be a problem to put subdomains in a folder like:
/home/user/domains/domain.com/subdomains/sub/public_html/
?
I'll leave this for DirectAdmin staff to respond to; the design is their decision :). I will say that I don't see much of a difference. Since others have requested even more flexibility, I'm not sure what I'd do if I were an author of DirectAdmin; it's probably a good thing I'm not ;) .

But I don't see what it's got to do with the DNS part of your question. They're really two different questions.

Jeff
 
If you want to use a different DocumentRoot structure for subdomains, you can. You'd need to edit the virtual_host_sub.conf and virtual_host_secure_sub.conf templates.. change the path around to whatever you want. Note that DA will still create the old paths, you'd have to create your new ones manually. You could also use subdomain_create_post.sh to delete the DA path and create your own to fully automate it.
http://help.directadmin.com/item.php?id=2

For creating a subdomain as a full domain, it's about 20,000 times easier to give the subdomain it's own zone. The main reason is zones would get extremely messy to manage for DA.. plus when you delete that subdomain, DA would then have to go in an try and figure out which record goes where. Not to mention that an MX record is also needed, so that you can get email to your subdomain. Treating the zone as it's own domain means zero extra work, no mess and it just works. Regular subdomains are fine because there is nothing special about them, they don't have a full domain interface.

John
 
Back
Top