Forum Moderators: phranque

Message Too Old, No Replies

redirect domain.com/dir to dir.domain.com help

         

anarckie

6:18 pm on Jul 17, 2006 (gmt 0)

10+ Year Member



Hello, i've done searches and have tried everything i found but can not get it to work.

I have been using 'subdomains.domain.com/' for awhile and until recently Google has now begun spidering 'www.domain.com/subdomains/' in their index.

I want to avoid duplicate content problems so need a way to redirect it back to the subdomain in htaccess.

Here is what i have so far (doesnt work). I have tried other codes but i get errors. Thanks for the help.

-----------

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www¦sub1¦sub2¦sub3\.domain\.com
RewriteRule ^(.*)$ [domain.com...] [R=permanent,L]

RewriteRule ^(.*)/sub1/?$ [sub1.domain.com...] [L,R=301]
RewriteRule ^(.*)/sub2/?$ [sub2.domain.com...] [L,R=301]
RewriteRule ^(.*)/sub3/?$ [sub3.domain.com...] [L,R=301]

-----------

jdMorgan

10:50 pm on Jul 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two questions:
1) What code or method do you currently use to get from sub.example.com to example.com/sub? Or are you doing something different?
2) *How* does you new code not work? Does it do nothing, throw an error, or loop until the max redirect limit is reached?

Jim

anarckie

5:00 pm on Jul 18, 2006 (gmt 0)

10+ Year Member



1. Not sure, i set it up through my CPanel. But it does not have anything in the .htaccess.

2. With the code above - it does nothing. Both ways to view the pages work.

jdMorgan

5:09 pm on Jul 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, if this is a standard cPanel subdomain implementation, it is likely that you'll need to put the rule to redirect each subfolder to a subdomain *in the .htaccess file in that subfolder*. You won't be able to do this all from the 'main' .htaccess file, because that file won't be processed for a subdomain request.

Jim

[edited by: jdMorgan at 5:10 pm (utc) on July 18, 2006]

anarckie

4:12 pm on Jul 21, 2006 (gmt 0)

10+ Year Member



Jim, can you provide me with an example of code that would work if i put it in the subdomain folder that will redirect if it's coming from www and not the subdomain?

Thanks for the help.

anarckie

5:58 pm on Jul 24, 2006 (gmt 0)

10+ Year Member



Anyone?