Reputation: 25
I have two domains (example.com
and example2.com
) that direct to the same location. I want to redirect one of the domains (example2.com
) to a directory (example.com/dir
), without any of the following occurring:
example.com/dir
example2.com
but does not load contents of example.com/dir
other than index.html
example.com
also redirects to example.com/dir
So that:
example2.com
shows the contents of example.com/dir
example2.com/page.html
shows the file example.com/dir/page.html
Thanks in advance
Upvotes: 2
Views: 50
Reputation: 24448
So given that both domains point to the same document root, then you should be able to use this rule to rewrite example2.com
to /dir
.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example2\.com [NC]
RewriteRule ^(.*)$ /dir/$1 [L]
If that is not the case and they are not on the same servers, you will have to use mod-proxy
[P]
to accomplish this task. This would go on the example2.com .htaccess.
RewriteEngine On
RewriteRule ^(.*)$ http://example.com/dir/$1 [P]
Upvotes: 1