Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

When someone goes to my url say http://abc.com, it automatically goes to the public_html folder of my host's server.

If i go into the cpanel and create a subdomain say http://123.abc.com, it lets me choose a folder on my server that it will always look in. For example http://123.abc.com will always look in the folder public_html -> 123.

How can I tell my main domain of http://abc.com to look into a specific folder that i create in my public_html folder? Right now i'm doing a 301 redirect via the cpanel, but I feel like there's an easier way to do this.

share|improve this question
There's really nothing wrong with using the redirect. Your hosting company would know if it's possible to change the root folder of your site. –  Chris S Sep 1 '10 at 18:51
Chris please put your comment as an answer and i'll accept it. I didn't know that it was ok to just do a 301 redirect. –  Catfish Sep 17 '10 at 15:15

1 Answer 1

The way it's generally done is by using an apache virtual host file.

#Server configuration

Listen 80

# This is the "main" server running on
ServerName server.domain.com
DocumentRoot /www/mainserver

# This is the other address

DocumentRoot /www/example1
ServerName www.example1.com

# Other directives here ...


DocumentRoot /www/example2
ServerName www.example2.org

# Other directives here ...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.