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

Issue with redirect looping

 8:16 pm on Nov 28, 2012 (gmt 0)

The following rewrite is resulting in an infinite loop.

Basically I want anything that goes to blog which contains letters or - for 2 directories after blog to redirect to tags using the $1.

I thought the following would work but it's not doing a good job as it results in the rewrite to be like this:


This is not the desired effect but I assume it's doing that because it's redirecting again after the initial redirect. I tried to resolve that by checking request uri for the word tags. But that didn't resolve the problem :(

Any suggestions would be greatly appreciated.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/tags/
RewriteRule ^/blog/([A-z\-]*)/([A-z\-]*)/index.html$ http://www.example.com/blog/tags/$1/index.html [R=301,L]



 9:53 pm on Nov 28, 2012 (gmt 0)

So you want the rule to work for


but only if the request wasn't for



Look at that for a moment and you can start sorting out the problems.


 10:14 pm on Nov 28, 2012 (gmt 0)

I do see the problem, it's reading itself.

But how do I go about telling it that it must have tags and more stuff here?


 10:42 pm on Nov 28, 2012 (gmt 0)

OMG! I'm a putz. I figured it out thanks!

RewriteCond %{REQUEST_URI} !^/blog/tags/
RewriteRule ^blog/([A-z\-]*)/([A-z\-]*)/index.html$ http://www.example.com/blog/tags/$1/index.html [R=301,L]


 11:32 pm on Nov 28, 2012 (gmt 0)

You MUST list the redirecting rule before the rule that rewrites.

It's a good idea to have a non-www/www canonicalisation rule after all other redirects and before the rewrite(s).

Make sure all your rules use RewriteRule syntax and NOT Redirect or RedirectMatch.

Do not redirect to a named index page. The correct URL ends with a trailing slash.

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