Reputation: 6398
I am planning to build a website that which have a domain and automatically generated sub-domains.
Ex : a user registering on http://www.domain.com so after registration he will get a sub-domain ie : user.mydomain.com ,this page is users page.
i am planning to do this with the following architecture:
domain.com/index.php/profile/user/username
where profile is the controller ,user is the function and username is the parameter ,so when a user entered username.domain.com ,i don’t want to redirect the page ,but i want show contents from “domain.com/index.php/profile/user/username” on username.domain.com. is there anyway to do this ? i have full access to hosting provider,so what method is useful & ease for me ? something like .htaccess ?? or any other ? actually i want to follow the blogger.com style on my website,one more think that i want to give option to users to allow custom domains instead of sub-domains.
i am little bit newbie here,expecting detailed reply.
Thank you . Note : i already posted this on codeigniter forum too , but Stackoverflow is so fast & expert on this.
Upvotes: 2
Views: 1300
Reputation: 64700
You are looking at DNS wildcard hosting: take a look at http://sebastiano.ezion.cc/2008/03/08/wildcard-dns-and-php/ for an example, but you'll need to fetch the $_SERVER["HTTP_HOST"]
value, then extract the first part of the domain to get the username. You can then show the proper content.
How you do the actual DNS wildcard depends on your hosting provider.
Upvotes: 2