Forum Moderators: phranque

Message Too Old, No Replies

Shared directory - redirect

from domaina.com/here/ to domainb.com/here/

         

limbo

10:00 am on Jun 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi

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

jdMorgan

1:18 pm on Jun 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you specify a domain as you did in your first rule, that makes it a redirect. Since you did not specify a 301 by using [R=301], that makes it a 302 redirect by default.

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]

Jim

limbo

9:08 pm on Jul 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Jim

You put us on the right track.

We ended up doing something similar to what you suggested in the sub directory. Using rewrite (I think ;))

jdMorgan

9:58 pm on Jul 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Using rewrite (I think)

Do be sure you got this right. Otherwise, you will 'expose' the domaina/here filepath to the client (browser, googlebot, etc.) as a URL, and you will not likely be happy.

Jim