# 
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#

<VirtualHost ${pac.curINetAddr.inetAddr}:80 ${pac.oldINetAddr.inetAddr}:80>

    ServerName ${dom.name}
    ServerAlias *.${dom.name}
    ServerAdmin webmaster@${dom.name}

    SuexecUserGroup ${dom.user.name} ${pac.name}

    DocumentRoot /home/doms/${dom.name}/htdocs

#if( ${dynamicWeb} )
    Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
    Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
#end

    <Directory />
        Options -ExecCGI ${includes} ${indexes} ${multiviews} +SymLinksIfOwnerMatch
    </Directory>

    <Directory /home/doms/${dom.name}/>
        AllowOverride AuthConfig FileInfo Indexes Limit
    </Directory>

#if( ${dynamicWeb} )
    <Location /cgi-bin/>
        SetHandler cgi-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
    </Location>

    <Location /fastcgi-bin/>
        SetHandler fcgid-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
    </Location>
#else
    <Location /cgi-bin/>
        Redirect 501 /
    </Location>

    <Location /fastcgi-bin/>
        Redirect 501 /
    </Location>
#end

    RewriteEngine On
    RewriteOptions Inherit

    RewriteCond %{REQUEST_URI} !^/cgi-bin/
    RewriteCond %{REQUEST_URI} !^/fastcgi-bin/    
    RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
    RewriteCond /home/doms/${dom.name}/subs/#[[${tolower:%1} ]]# -d
    RewriteRule ^(.*) /home/doms/${dom.name}/subs/#[[${tolower:%1}$1 ]]# [last]     
    
#if( !${htdocsfallback} )
    RewriteCond %{REQUEST_URI} !^/cgi-bin/
	RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
    RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
    RewriteCond /home/doms/${dom.name}/subs/#[[${tolower:%1} ]]# !-d
    RewriteRule ^(.*) - [redirect=404,last]
#end

#if( ${dynamicWeb} )
    AddType application/x-httpd-php .php .php5 .php4 .php3
    Action application/x-httpd-php /fastcgi-bin/phpstub
#end

</VirtualHost>

<VirtualHost ${pac.curINetAddr.inetAddr}:443 ${pac.oldINetAddr.inetAddr}:443>

    ServerName ${dom.name}
    ServerAlias *.${dom.name}
    ServerAdmin ${dom.user.name}@${dom.name}

    SuexecUserGroup ${dom.user.name} ${pac.name}

    SSLEngine On
    SSLCertificateFile /etc/apache2/pems/default.pem
    SSLCertificateChainFile /etc/apache2/pems/default.chain.pem
    SSLCertificateFile /etc/apache2/pems/${pac.name}.pem
    SSLCertificateChainFile /etc/apache2/pems/${pac.name}.chain.pem

    DocumentRoot /home/doms/${dom.name}/htdocs-ssl

#if( ${dynamicWeb} )
    Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/
    Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/
#end

    <Directory />
        SSLRequireSSL On
        Options -ExecCGI ${includes} ${indexes} ${multiviews} +SymLinksIfOwnerMatch
    </Directory>

    <Directory /home/doms/${dom.name}/>
        AllowOverride AuthConfig FileInfo Indexes Limit
    </Directory>

#if( ${dynamicWeb} )
    <Location /cgi-bin/>
        SetHandler cgi-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
    </Location>

    <Location /fastcgi-bin/>
        SetHandler fcgid-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
    </Location>
#else
    <Location /cgi-bin/>
        Redirect 501 /
    </Location>

    <Location /fastcgi-bin/>
        Redirect 501 /
    </Location>
#end
    
    RewriteEngine On
    RewriteOptions Inherit
    
    RewriteCond %{REQUEST_URI} !^/cgi-bin/
    RewriteCond %{REQUEST_URI} !^/fastcgi-bin/    
    RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
    RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# -d
    RewriteRule ^(.*) /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1}$1 ]]# [last]    
    
#if( !${htdocsfallback} )
    RewriteCond %{REQUEST_URI} !^/cgi-bin/
	RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
    RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:443)?$ [novary]
    RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# !-d
    RewriteRule ^(.*) - [redirect=404,last]
#end

#if( ${dynamicWeb} )
    AddType application/x-httpd-php .php .php5 .php4 .php3
    Action application/x-httpd-php /fastcgi-bin/phpstub
#end

</VirtualHost>
