Subdomains and address bar
- by Priednis
I have a fairly noob question about how subdomains work.
As I understand at first the DNS server specifies that a request for certain subdomain.domain.com has to go to the IP address of domain.com, and the webserver at domain.com further processes the request and displays the needed subdomain page.
It is not entirely clear to me how (for example Apache) server does it. As I understand there can be entries in vhosts.conf file which specify folders that contain the subdomain data. Something like:
<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>
<VirtualHost *>
ServerName subdomain.domain.com
DocumentRoot /home/httpd/htdocs/subdomain/
</VirtualHost>
and there also can be redirect entries in .htaccess files like
rewritecond %{http_host} ^subdomain.domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/subdomain/ [r=301,nc]
however in this case the user gets directed to the directory which contains the subdomain data but the user gets "out" of the subdomain.
I would like to know - how, when going to subdomain.domain.com the subdomain.domain.com, beginning of address remains visible in the address bar of the explorer?
Can it be done by an alternate entry in .htaccess file?
If a VirtualHost entry is specified in the vhosts.conf file, does it mean, that a new user account has to be specified for access to this directory?