Welcome to WebmasterWorld Guest from 54.221.87.97

Forum Moderators: phranque

Message Too Old, No Replies

Redirecting a domain name to a subdirectory of a different domain

     

Shatner

10:02 pm on Apr 15, 2011 (gmt 0)



Wasn't sure where to ask this, apologies if it's in the wrong spot.

So I have a primary domain, let's call it primary.com.

I also have a secondary domain, let's call it secondary.com

I have these directories:

primary.com/one/
primary.com/two/
primary.com/three/

I would like to set up a redirect which makes the second one...

secondary.com/two/

Without affecting
primary.com/one/
primary.com/three/
primary.com

Is that possible? I can't quite wrap my head around out how to do it, but it seems like it should be doable.

Hopefully I explained that well enough.

phranque

12:05 am on Apr 16, 2011 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



what type of server is primary.com running on?

Shatner

1:27 am on Apr 16, 2011 (gmt 0)



Linux.

phranque

9:54 am on Apr 16, 2011 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



apache?

Shatner

11:31 pm on Apr 17, 2011 (gmt 0)



Yes. Apache.

phranque

8:29 am on Apr 18, 2011 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



if you put this in the .htaccess file in your document root directory it will redirect exactly the subdirectory "/two/" to the "secondary.com" domain, but none of the contents of "two" will be redirected:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^two\/$ [secondary.com...] [R=301,L]

is that what you were looking for?

g1smd

8:41 am on Apr 18, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Forward slashes never need escaping.

RewriteRule ^two/(.*) http://www.example.com/$1 [R=301,L]

Shatner

12:05 am on Apr 19, 2011 (gmt 0)



Close, but I actually do also want the contents of "two" to be redirected.

At the same time if someone types in
secondary.com/one/

I want it to redirect to
primary.com/one/

Including all the contents on all of those directories in this.

Again, apologies if I'm explaining this in a confusing way.