homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

redirects going to wrong page entirely

 10:54 pm on Jan 11, 2012 (gmt 0)


I have a weird one here.

My redirects seem ok, but in some cases, the page being redirected to is not correct.

They all seem to be cases like the following

RewriteCond %{REQUEST_URI} ^/forum/discussion/71/*
RewriteRule ^(.*)$ /newpath/topic/growing-tomatoes/ [R=permanent,L]

RewriteCond %{REQUEST_URI} ^/forum/discussion/711/*
RewriteRule ^(.*)$ /newpath/topic/cutting-grass/ [R=permanent,L]

...where the bottom one is also ending up athe the top one;s destination. in other words discussion 711 is going to the growing tomatoes page.

Why is this?

Thanks for your help.



 11:34 pm on Jan 11, 2012 (gmt 0)

71/* means 0 more slashes so matches both 71<anything> (and thereby 711) and 71///////<anything>

The rule for redirects is that the most specific redirects go first, i.e. reverse the order of the two rules.

Additionally, you might (or might not) want to change the * to a + too.

The rule target should also include both protocol and hostname.

Finally, there is no need for the RewriteCond here. The URL test should be directly in the RewriteRule RegEx pattern (and without leading slash).


 11:47 pm on Jan 11, 2012 (gmt 0)

great, fixed! Thank you so much.

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