Mapping subdomains to parametered web pages in Apache
Mapping john.webserver.com to http://www.webserver.com/user.php?name=john
is just by changing a few parameters in http.conf file
In httpd.conf file,
<VirtualHost se.rv.er.ip.ad.re.ss>
ServerAdmin info@servername.com
DocumentRoot /var/www
ErrorLog /var/log/apache/apache-error.log
TransferLog /var/log/apache/apache.log
ServerName www.servername.com
ServerAlias *.servername.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.servername\.com
RewriteRule ^/$ http://www.servername.com/user.php?user=%1
</VirtualHost>
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 ^/$ http://www.servername.com/user.php?user=%1 parameter section which is grabbed as subdomain name will be our value for user variable to user.php file.
- 0 Comment
- Halil Demirezen
- 04 Jun 2008, 18:00
-
You must be login first or sign-up for an account to post comments.
Maybe you should look at these also:
USERBOX
CATEGORIES
MOST READ TODAY
LAST ADDED
- Using iPhone internet sharing over bluetooth under Linux
- Using USB sound card with amarok
- Multi-conditional search and replace (clearing a ftp trojan script example)
- Disabling ipv6 functionality
- How to convert a mp3 file
- How to choose the fastest Debian mirror
- Disabling reverse dns lookups in ssh
- Rewriting destination ip address
- Deleting A File By It's Inode Value
- Learning which libraries are used for a binary
