website - How to create a site instance per subdomain -


i create web platform each customer own site uservoice.com

example:

  • main website : uservoice.com
  • customer 1: cust1-subdomain.uservoice.com
  • customer 2 : cust2-subdomain.uservoice.com

the objective customer can enter site via own url & login page.

does know how that? how avoid sub-directory subdomain , copy files? looking clean , scalable solution.

i think solution name-based virtual host.

for example domain cust2-subdomain.uservoice.com display content located in different folder documentroot address unchanged. server recognize domain , send appropriate content.


if using apache: need uncomment line in httpd.conf file if not uncommented:

include conf/extra/httpd-vhosts.conf 

then should edit /usr/local/apache2/conf/extra/httpd-vhosts.conf.

<virtualhost *:80>     serveradmin you@uservoice.com     documentroot "/usr/local/apache2/docs/uservoice.com"     servername uservoice.com     serveralias www.uservoice.com     errorlog "logs/uservoice.com/error_log"     customlog "logs/uservoice.com/access_log" common </virtualhost>  <virtualhost *:80>     serveradmin cust2@uservoice.com     documentroot "/users/customers/cust2/www"     servername cust2-subdomain.uservoice.com     serveralias www.cust2-subdomain.uservoice.com     errorlog "logs/cust2/error_log"     customlog "logs/cust2/access_log" common </virtualhost> 

the first section site , second 1 cust2's site. cust2 put site www folder located in home directory. put content in old documentroot. (you need customize /usr/local/apache2/conf/extra/httpd-vhosts.conf).


Comments