0

Possible Duplicate:
How to let PHP to create subdomain automatically for each user?
Create Subdomains on the fly with .htaccess (PHP)

Third level domain created by PHP

I have a user database (on LAMP) and I would like to get users able to create their own domain as http://user1.mysite.com, http://user2.mysite.com.

How is the best road to do this?

Community
  • 1
  • 1
Uncoke
  • 1,832
  • 4
  • 26
  • 58
  • 1
    Third level domain also known as subdomain. – tomsseisums Mar 20 '12 at 14:17
  • http://stackoverflow.com/questions/183928/how-to-let-php-to-create-subdomain-automatically-for-each-user or http://stackoverflow.com/questions/586129/create-subdomains-on-the-fly-with-htaccess-php or http://stackoverflow.com/questions/5929129/can-i-dynamically-create-subdomains-php-htaccess-with-godaddy-hosting – Manse Mar 20 '12 at 14:18
  • 1
    you have to setup DNS to route all subdomains to your domain in order for this to work. – Cfreak Mar 20 '12 at 14:19
  • Why upvote or favorite a soon-to-be-closed question? – Your Common Sense Mar 20 '12 at 14:20
  • @Uncoke, Have you found any solution? I have the same question. – Naren Verma Oct 07 '17 at 07:00

1 Answers1

0

Set up a catchall on your DNS to point to your servers IP address.

Then, depending on what you want to do, set up the dub-domains on the server.

If you want them to host their own pages, you will need to set up virtual hosts in the apache config for each one.

If you want their sub domain to point to a page on your site (i.e: john.domain.com is the same as domain.com/user.php?user=john ) then you should be able to set up a *:80 virtual host to catch them all. Then you would use .htaccess to remap the sub domain to the static page.

David Houde
  • 4,835
  • 1
  • 20
  • 29