Forum Moderators: phranque

Message Too Old, No Replies

301 Redirect - Moved a Sub-Directory and its sub to a new path

within the same domain

         

Imaster

8:43 pm on Jun 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I would like to do a 301 redirect for the following:

http://www.example.com/a/b/c/... now redirects to
http://www.example.com/a/b/e/...

[... may represent any number of further sub-directories.]

So basically, a request for http://www.example.com/a/b/c/dir1 should redirect to http://www.example.com/a/b/e/dir1/
Similarly, a request for http://www.example.com/a/b/c/dir2 should redirect to http://www.example.com/a/b/e/dir2/

Any inputs would be appreciated. If possible, please do direct me to threads which discuss the same issue. I tried looking up many posts, but could not find anything concrete.

Thanks in advance.

Imaster

8:47 pm on Jun 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I forgot to mention one more thing:

In the example: a request for http://www.example.com/a/b/c/dir1 should redirect to http://www.example.com/a/b/e/dir1/

In the above the first level directory namely "a" would also be changing as there are many directories.

So,
http://www.example.com/a/b/c/dir1 should redirect to http://www.example.com/a/b/e/dir1/
http://www.example.com/x/b/c/dir1 should redirect to http://www.example.com/x/b/e/dir1/
http://www.example.com/y/b/c/dir1 should redirect to http://www.example.com/y/b/e/dir1/ and so on...

jdMorgan

5:17 pm on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> http://www.example.com/a/b/c/... now redirects to http://www.example.com/a/b/e/.../

Something like:


RewriteRule ^a/b/c/(([^/]+)/)*[^/]+)$ http://www.example.com/a/b/e/$1/ [R=301,L]

(I assume here that "..." is not blank and does not end with "/".)

Jim