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

I am working on one site, in which i need to create a sub domain for each user.

For e.g, my xite:

www.demo.com

And user name is :: Mark then sub domain for that user will be as below,

mark.demo.com

I need to know that what is the proper way to do like the above.

I am running on PHP.

Thanks,
Avinash

share|improve this question

migrated from stackoverflow.com Jan 11 '10 at 13:30

This question came from our site for professional and enthusiast programmers.

    
What kind of web server are you running? Apache? –  Chris Clark Jan 11 '10 at 13:19
    
Yes, i am using apache –  Avinash Jan 11 '10 at 13:21

2 Answers 2

u can use mod_rewrite

tutorial: http://www.easymodrewrite.com/example-subdomains

share|improve this answer
    
Hi, i have got a lot from the link you have given, but its not working for my case. May problem in my code or something else.. I am not getting what is %2 and $1 in the example they have provided on the above link.. Can you please explain about that Thanks –  Avinash Jan 12 '10 at 6:10

You will need to configure a DNS A record for each subdomain. You could optionally configure a wildcard subdomain, CNAMEd to the A record, but this is inadvisable. If you are not running your own DNS server, you will need to use the facilities offered by your domain registrar / ISP to configure the domains.

Once that's in place, you need to configure apache virtual hosts, one per subdomain. See http://httpd.apache.org/docs/2.0/vhosts/ for information on apache virtual hosts.

share|improve this answer

Your Answer

 
discard

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.