Tuesday, January 25, 2011

.HTACCESS Subdomain instead of .CONF Subdomain

I have 3 sample domains and would like to converting this .conf to .htaccess so that I don't have to restart my Apache all the time once I've updated my subdomain settings.

NameVirtualHost *:80
<VirtualHost    *:80>
    ServerName www.myserver.com
    DocumentRoot /www
</VirtualHost>
<VirtualHost    *:80>
    ServerName marhazk.myserver.com
    DocumentRoot /www/marhazk.com
</VirtualHost>
<VirtualHost    *:80>
    ServerName perfectworld.myserver.com
    DocumentRoot /www/perfectworld.com
</VirtualHost>

Any idea how?

  • You can't put VirutalHost directives in a .htaccess file. How would Apache even know where to look for the .htaccess file in the first place?

    On the Apache help pages, notice that the context is limited to the server config only.

    From Chris S
  • This is not possible to use virtual host settings in htacess files but you might want to take a look to Apache Mass Virtual Host settings, this allow to have dynamic mapping between servername and documentroot http://httpd.apache.org/docs/2.0/vhosts/mass.html

    From radius

0 comments:

Post a Comment