From Leo's mailbag:
> From: A Computer User
> Sent: May 7, 2006
> To: Ask Leo!
> Subject: redirecting a domain to a subdirectory
>
> Leo,
> --------------
> In "how_do_i_direct_my_web_traffic_to_a_single_domain", you
> show how to use Apache's RewriteEngine to redirect several
> domain name variants to your main web site.
>
> Is it possible to do something similar to redirect secondary
> domains to subdirectories on the main site? For example, is
> it possible to use it to redirect
> <http://www.otherdomain.tld> to
> <http://www.maindomain.tld/otherdomain/>, or
> <http://subdomain.maindomain.tld> to
> <http://www.maindomain.tld/subdomain/>?
>
> Currently, these simply show the same main page, but with
> different domain names.
Absolutely. Visit http://hotmailtips.com and you'll see it in action.
That particular one was done using META REFRESH tags in an index.html:
<html>
<head>
<meta http-equiv="refresh"
content="o;url=http://ask-leo.com/msn_hotmail.html;">
</head>
<body>
<p>If you're not redirected, click <a
href="http://ask-leo.com/msn_hotmail.html">here</a>.</p>
</html>
But you can also do it more transparently with URL rewriting:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.otherdomain\.tld [NC]
RewriteRule ^/(.*) http://www.maindomain.tld/otherdomain/$1
[L,R=permanent]
(Untested, but something at least *like* that should work).
There are also ways to configure your web server to do it, but exactly how
depends on the web server).
Thanks for asking,
Leo