Recipe 5.16 Turning Directories into Hostnames


You want to migrate pathnames under a single hostname to distinct hostnames.


Use RewriteRule in httpd.conf:

RewriteRule "^/(patha|pathb|pathc)(.*)" "http://$$2" [R] RewriteRule "^/([^./]*)(.*)" "http://$$2" [R] RewriteRule "^/~([^./]*)(.*)" "http://$$2" [R]


The first recipe redirects requests of the form to a different host, such as, but only for those requests in which pathseg is patha, pathb, or pathc.

The second recipe does the same thing, except that any top-level path segment is redirected in this manner.

The third recipe splits the difference, redirecting all "user" requests to distinct hosts with the same name as the user.

See Also


Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: