Skip to main content

Dynamic DocumentRoot for Sub-Domains.

If you have plenty of sub-domains and every subdomain routes in another directory on the server, This can be done dynamically.

Add folling in httpd.conf/httpd-vhost.conf

<\VirtualHost *:80\>
    ServerName www.kishor.com
    ServerAlias www.kishor.com
    ServerAlias kishor.com
    ServerAlias *.kishor.com   
    RewriteEngine  on
    RewriteCond    %{HTTP_HOST}  ^kishor.com
    RewriteRule    ^(.*)$        /var/www/html/$1 [L]
    RewriteCond    %{HTTP_HOST}  ^www.*
    RewriteRule    ^(.*)$        /var/www/html/$1 [L]
    RewriteCond    %{HTTP_HOST}  ^(.*)\.kishor\.com
    RewriteRule    ^(.*)$        /%1/$1 [L]
    ErrorDocument 404 http://www.kishor.com
<\/VirtualHost\>



As you can see, the DocumentRoot is //var/www/html/. This is the directory where all other sub-directories for the sub-domains are located.

We use the RewriteEngine to decide which directory we want. The first RewriteCond is to route the domain without any sub-domain into the www directory. The second RewriteCond demonstrates how the third RewriteCond works with any subdomain.

www.kishor.com  =>  /var/www/html/www/
test.kishor.com  =>  /var/www/html/test/
gavali.kishor.com  =>  /var/www/html/gavali/


Finally setup your domain as wildcard domain *.kishor.com in your DNS and enjoy the Dynamic Hosting.

Comments

Anonymous said…
With this, the on line casino 1xbet korea account first had to be loaded with a credit score. In the meantime, nevertheless, it's also potential to pay with Skrill and not using a|with no} earlier top-up. Account openings under a false name are inconceivable, additionally by verification abuse is nearly of} inconceivable.

Popular posts from this blog

DKIM PROXY FOR OUTGOING MAIL IN POSTFIX

1.  Download DKIM proxy         wget http://downloads.sourceforge.net/dkimproxy/dkimproxy-1.3.tar.gz         perl -MCPAN -e'CPAN::Shell->install("Net::Server")'         perl -MCPAN -e'CPAN::Shell->install("Mail::DKIM")'         perl -MCPAN -e'CPAN::Shell->install("Mail::DKIM")'                tar -zxvf dkimproxy-1.3.tar.gz         ./configure --prefix=/usr/local/dkimproxy         make install         2. Generate Public and Private Key         Generate a private/public key pair using OpenSSL:                 openssl genrsa -out private.key 1024             opens...