Forum Moderators: phranque
What would be the best way to redirect: domainda.com/here/ to domainb.com/here/
There is a trick mind; domainb.com/here/ is running off a CMS installed on domaina.com/here/ - they are not separate entities, so a redirect 301 did not work for me.
I'm using .htaccess (+ domain mapping) to display the contents of domaina.com/here/ on domainb.com/here/
Header append Vary host
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domainb\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/here
RewriteRule ^.*$ http://www\.domainb\.com/here%{REQUEST_URI} [L]
(inside the root of domaina.com)
I'm also rewriting the non www to www version with these:
RewriteCond %{HTTP_HOST} ^domaina.com
RewriteRule (.*) http://www.domaina.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domainb.com
RewriteRule (.*) http://www.domainb.com/$1 [R=301,L]
Any help on how to get that working would be really appreciated.
Cheers, Limbo
As with your other recent thread, there seems to be confusion between the rewrite/redirect "to" and rewrite/redirect "from" URLs and URL-paths, confusion between what is a URL and a what is a filepath, and confusion between what is an external redirect and what is an internal rewrite, and these make the questions rather impenetrable.
All I can say for sure here is that if you are targeting a *file* inside the server, and you wish to pass the *current* HTTP request to it, then neither a protocol nor a domain name belong in that target path, as neither have any meaning *inside* a server.
So, if the following does not work, then either the question wasn't posed fully/correctly, or you will need to reverse-proxy domainb to domaina:
RewriteCond %{HTTP_HOST} ^www\.domainb\.com [NC]
RewriteCond $1 !^here/
RewriteRule ^(.*)$ /here/$1 [L]