Setup a ServerAlias only for a Subdomain

liz@lele

New member
Joined
Jan 15, 2010
Messages
3
Hi all.
I'm trying to setup a ServerAlias but i need it to work only on a subdomain.
Let me explain:
I create the subdomain example.com and a subdomain cms.example.com; and all works correct.
After, usign the tools "Custom http configuration", i can setup a ServerAlias for the domain, let say, subd1.example1.com (yes, is another domain is not a typo) and all work correct: if i point my broswer to subd1.example1.com it show me the content of www.example.com.
Now, what i have to do is to add a ServerAlias subd2.example1.com (and another time, yes, is example1.com, is not a type:P) that point to cms.example.com (the subdomain i created above): the only way i have to do is to manually edit the /usr/local/directadmin/data/user/*user*/http.conf and add the line at the beginning of the virtualhost of the subdomain. But once i made a little modification to the domains, directadmin overwrite all my modification to the http.conf.

I have already saw that i could create the subdomain as a new domain, but often i have an application that need the folder structure as directadmin create (and no, i don't change the web application: this will be eventually the last option i take into consideration:P).

So, is there a way to do what i need? i have full access to the server and to the dns of all domains i want to work with.

Thanks in advance to you all, and sorry for my bad english: let me know is something is not clear.

Daniele
 
Last edited:
After you manually change the /usr/local/directadmin/data/user/USER/http.conf file you can chattr it so DirectAdmin can't change it.

See man chattr for documentation.

Jeff
 
Thank for your answer.
But if i chattr the file (with the -i option guess, that is the only that seems to make it unchangeable) what happen if from DA panel i try to setup a new domain? Will this generate an error? With that option, in fact, don't think that DA will be able to write the new information about that new domain.
Or need to use the '-a' option that let only to append the new information at the end?I am sure that DA always write the information at the bottom of the file when a new domain is created?

Thanks again

Daniele
 
I've never tried anything but -i (immutable). You're right; if you make the file immutable you won't be able to add another domain to that user. I've never tried -a, but if you do I'd imagine that you'd still have problems, especially when trying to modify or remove a domain.

Another way to add an alias to a subdomain would be to create your own include file (don't forget the include directive) and control it completely manually.

Jeff
 
Another way to add an alias to a subdomain would be to create your own include file (don't forget the include directive) and control it completely manually.

Thanks, think this is a good advice.
To manually control it, is enough if i copy the right <virtualhost www.xxx.yyy.zzz:80>...</virtualhost> in the /usr/local/directadmin/.../httpd.conf and place it in an appropriate file (i'll find where to place it)? or are there other files where i need to check? doing so, will DA 'see' the new subdomain? is not so important, but would be perfect if so.

Thanks again

Daniele
 
DirectAdmin will see the subdomain if you set it up under DirectAdmin. I'm not sure why DirectAdmin has to see the subdomain.

Apache will see the subdomain if you do what I suggested.

You really can't do both because at some point, unless you chattr -i the user-specific httpd.conf file DirectAdmin will re-insert the subdomain and you'll have duplicate information.

Jeff
 
Back
Top