Welcome to WebmasterWorld Guest from 54.196.244.186

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

redirect from one folder to another not working

     
2:04 pm on Jul 1, 2011 (gmt 0)

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 0


Hi,

I know this sounds like such a simple question, but nothing I've tried actually works.

All I want to do is redirect say

www.domain.com/folder1/name/id/1 to www.domain.com/folder2/name/id/1

The rule should redirect all pages within folder1, to folder2


Closest I get is:

RewriteCond %{REQUEST_URI} ^/folder1/*
RewriteRule ^(.*)$ [domain.com...] [R=301,L,NC]

...but it ends up like /folder1/folder2/#*$!#*$! instead.

What am I doing wrong please?
8:47 pm on July 1, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12709
votes: 244


You're not capturing the string "folder1" by itself. You have to capture it in order to get rid of it. Or, in this case, to replace it. Don't do anything else with the rest of the address; you don't need anchors unless you've carelessly used the "folder1" name in some other unrelated location too.

Use "example.com". The forums convert everything else-- even if it's just as phony-- into an active link. We need to see what you actually typed.
11:47 am on July 2, 2011 (gmt 0)

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 0


Hi Lucy,

I was using this:

RewriteCond %{REQUEST_URI} ^/folder1/*
RewriteRule ^(.*)$ http://www.example.com/folder2/$1 [R=301,L,NC]
11:57 am on July 2, 2011 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


The
(.*)
pattern captures ALL of the requested URL. The
(.*)
pattern is greedy, promiscuous and ambiguous.

Adjust the pattern to capture only the bits you want to re-use in the new URL request.

RewriteRule ^unwanted(wanted)$ http://www.example.com/folder2/$1 [R=301,L]
11:48 am on July 3, 2011 (gmt 0)

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 0


Thanks everyone.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members