VirtualDocumentRoot Domains and Subdomains

Is it possible to have VirtualDocumentRoot for normal domains and subdomains? or







What i have so far: Pastebin - VirtualDocumentRoot Domains and Subdomains

The normal domain works except the subdomains, appearently it always redirects to the normal domain. This information i used is coming from Stackoverflow - Apache-multiple-virtualdocumentroot

# get the server name from the Host: header
UseCanonicalName Off

# this log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    VirtualDocumentRoot /var/www/%-2.0.%-1/web

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug
    ErrorLog /var/log/apache2/vhosts-error.log
    CustomLog /var/log/apache2/vhosts-access.log combined

    ServerSignature On
<VirtualHost *:80>
    ServerAlias *
    VirtualDocumentRoot /var/www/%-2.0.%-1/subdomains/%-3

Update v2 [worked for me, just ignore the subdomains till now..]

<VirtualHost *:80>
    Options Indexes FollowSymLinks

    VirtualDocumentRoot /var/www/%-2_%-1/web/

    <Directory />
            AllowOverride none

    <Directory "/var/www/*/web/">
        RewriteEngine on
        RewriteBase /
        # If a directory or a file exists, use it directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward it to index.php
        RewriteRule . index.php [L]

        <Files sitemap.xml>
            RewriteEngine Off

        LogLevel debug
        ErrorLog /var/log/apache2/vhosts-error.log
        CustomLog /var/log/apache2/vhosts-access.log combined


You can specify a folder on your server for each domain and/or sub-domain :) See for samples.

If you get problems with the subdomain or domain please check your DNS record to see if subdomains are enabled for your domain. Else add a 'A' record with your subdomain or an alias like * Basiccly what this does, is pointing the subdomain to your server IP address.

Check this article for an easy guide to DNS :

Need Your Help

How can I organize my code to optionally provide a backing view for my logic layer?

ios architecture custom-component

I'm a bit sceptic wether this belongs to stackoverflow or not, please let me know if I should post to codereview or programmers instead.

jquery unbind method

jquery unbind

if my html looks like this: