Forum Moderators: phranque

Message Too Old, No Replies

.htaccess directory redirect

Is this how it's done?

         

WebWalla

11:16 am on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've read a little about .htaccess but I'm certainly no expert. I would like to redirect browsers and spiders from one directory to another on the same domain, maintaining PR and links if possible. Would this simple line be enough if my domain is example.com? ...

Redirect 301 /dir [example.com...]

Thanks.

jdMorgan

2:37 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, that would do it. However, there's the danger that due to the way that Redirect uses prefix-matching, you may unintentionally redirect requests for files beginning with the name "dir". Since you only want to redirect directory-level requests, I'd suggest:

Redirect 301 /dir/ http://www.example.com/newdir/

This will redirect requests for "http://www.example.com/dir/anything", but won't redirect requests for "http:/www.example.com/direct.html". Basically, it's just "safer" because it is more specific.

Jim

WebWalla

2:47 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Exactly what I needed, thanks.

Just for my own education, to develop this a little - I assume that the same line would be valid if I wanted to redirect this directory to a different directory on a different domain?

e.g. Redirect 301 /dir/ [newexample.com...]

jdMorgan

3:13 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, any canonical target URL can be used.
Jim