homepage Welcome to WebmasterWorld Guest from 23.22.179.210
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
redirect from one folder to another not working
starchild




msg:4333624
 2:04 pm on Jul 1, 2011 (gmt 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?

 

lucy24




msg:4333843
 8:47 pm on Jul 1, 2011 (gmt 0)

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.

starchild




msg:4334102
 11:47 am on Jul 2, 2011 (gmt 0)

Hi Lucy,

I was using this:

RewriteCond %{REQUEST_URI} ^/folder1/*
RewriteRule ^(.*)$ http://www.example.com/folder2/$1 [R=301,L,NC]

g1smd




msg:4334105
 11:57 am on Jul 2, 2011 (gmt 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]
starchild




msg:4334394
 11:48 am on Jul 3, 2011 (gmt 0)

Thanks everyone.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved