All .htacces and mod_rewrite answered - examples, tips and tricks Forum Index  

All .htacces and mod_rewrite answered - examples, tips and tricks Forum Index -> URLs - other tricks -> Virtual User Hosts
Author Message
admin
Site Admin


Joined: 18 Jul 2006
Posts: 89

PostPosted: Tue Jul 18, 2006 8:16 am    

Virtual User Hosts

Reply with quote

Assume that you want to provide www.username.host.domain.com for the homepage of username via just DNS A records to the same machine and without any virtualhosts on this machine.

For HTTP/1.0 requests there is no solution, but for HTTP/1.1 requests which contain a Host: HTTP header we can use the following ruleset to rewrite http://www.username.host.com/anypath internally to /home/username/anypath: RewriteEngine on

Code:
RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.host\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^www\.([^.]+)\.host\.com(.*) /home/$1$2

Source:http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
Back to top
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.   
View previous topic
View next topic
All .htacces and mod_rewrite answered - examples, tips and tricks Forum Index
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
FreeMind 1.1 Template by AU Templates