Mapping subdomains to parametered web pages in Apache


Mapping to
is just by changing a few parameters in http.conf file.

        ServerAdmin [email protected]
        DocumentRoot /var/www
        ErrorLog /var/log/apache/apache-error.log
        TransferLog /var/log/apache/apache.log
        ServerAlias *
        RewriteEngine on
        RewriteCond %{HTTP_HOST} !^www.* [NC]
        RewriteCond %{HTTP_HOST} ^([^\.]+)\.servername\.com
        RewriteRule ^/$

The lines for this feature,

RewriteEngine on activating rewrite option

RewriteCond %{HTTP_HOST} !^www.* [NC] the rule will not be applied to subdomain “www”

RewriteCond %{HTTP_HOST} ^([^\.]+)\.servername\.com subdomain section will be our parameter

RewriteRule ^/$ parameter section which is grabbed as subdomain name will be our value for user variable to user.php file.