Forum Moderators: phranque

Message Too Old, No Replies

How to do 301 redirect of both a-b-c.com/index.htm and a-b-c.com?

Without affecting the redirects of the subpages...

         

bewitch123

5:01 pm on Oct 9, 2009 (gmt 0)

10+ Year Member



Hi,

I've got a unique situation here that I can't find a solution. I want to redirect a-b-c.com to abc.com

I have already successfully do a 301 redirect for all my subpages in a-b-c.com, such as a-b-c.com/123.htm to abc.com/123.htm etc, and now its left with the index page.

I tried using the code:

Options +Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.htm\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)index\.htm$ [abc.com...] [R=301,L]

But this only allow me to redirect a-b-c.com/index.htm and not a-b-c.com

However I don't want to do a 301 redirect on the root directory because this will overwrite all the redirects of my subpages, which cause them all to be redirected to www.abc.com instead.

Is there a way I can redirect just both a-b-c.com and a-b-c.com/index.htm to abc.com without affecting the rest of the 100+ subpages?

jdMorgan

5:41 pm on Oct 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We don't know what your "100+ subpage" URLs look like, nor what your other rule(s) look like... So it's impossible to say.

However, it's obvious that you are not checking the %{HTTP_HOST} variable, and that only example.com/index.html and not example.com/ is redirected, so this rule won't accomplish all of your goals even as-is.

Another issue may be rule order; Put your redirects in order with external redirects first, in order from most-specific (fewest URLs affected) to least specific (most URLs affected), followed by your internal rewrites (if any), again ordered from most- least-specific.

Jim

g1smd

7:12 pm on Oct 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your rule redirects index-file URLs on any sub-domain to strip the filename and redirect to www for those.

You need a separate (following) rule to redirect non-www to www for all other URL requests.