Multi domain handling with mod_rewrite:
I have the following hosts
www.host1.com
www.host2.com
www.hostN.com
Each of these hosts is mapped to a different area of the application, e.g.
If the host is 'www.host1.com' then it should be redirected to 'www.host1.com/pages/gary'
If the host is 'www.host2.com' then it should be redirected to 'www.host2.com/pages/pete'
Ok, so I created a map, domain2handle.map:
www.host1.com gary
www.host2.com pete
----
RewriteMap domain2handle txt:/opt/apache/domain2handle.map
RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_URI} ^/$
RewriteCond ${lowercase:%{HTTP_HOST}} ^(.+)$
RewriteCond ${domain2handle:%1} ^([A-Za-z0-9]+)$
RewriteRule ^/(.*) /pages/%1 [R]
----
So the above checks the incoming host and redirects to the corresponding area.
Now my question is how do I go about checking that the right host is serving the right pages, e.g. how can I check that 'www.host1.com' isn't serving the 'pete' pages and vice-versa?
Right now it's possible for someone to come in on 'http://www.host1.com/pages/pete' which I want to deny.
I've been racking my brains trying to do this, but I can't figure it out... any help would be greatly appreciated!