We have answer of your question!

100% solved queries, no empty question

Question: How to make subdomain user accounts in a webapp


0

Advertisement


I am looking to allow users to control of subdomain of an app I am toying with, much like Basecamp where it is customusername.seework.com.

What is required on the DNS end to allow these to be created dynamically and be available instantly.

And how do you recommend dealing with this in the logic of the site? Htaccess rule to lookup the subdomain in the DB?

Question author Caleb-elston | Source

Answer


1


Advertisement


The way we do this is to have a 'catch all' for our domain name registered in DNS so that anything.ourdomain.com will point to our server.

With Apache you can set up a similar catch-all for your vhosts. The ServerName must be a single static name but the ServerAlias directive can contain a pattern.

Servername www.ourdomain.com
ServerAlias *.ourdomain.com

Now all of the domains will trigger the vhost for our project. The final part is to decode the domain name actually used so that you can work out the username in your code, something like (PHP):

list( $username ) = explode( ".", $_SERVER[ "HTTP_HOST" ] );

or a RewriteRule as already suggested that silently maps user.ourdomain.com/foo/bar to www.ourdomain.com/foo/bar?user=user or whatever you prefer.

Answer author Mat

Advertisement


Tickanswer.com is providing the only single recommended solution of the question How to make subdomain user accounts in a webapp under the categories i.e web-applications , dns , subdomain , account , . Our team of experts filter the best solution for you.

You may also add your answer!