Redirect in combination with a rewrite condition in htaccess

Posted by Robbert van den Bogerd on Stack Overflow See other posts from Stack Overflow or by Robbert van den Bogerd
Published on 2010-03-12T14:09:32Z Indexed on 2010/03/13 11:25 UTC
Read the original article Hit count: 289

Hi all!

I've got a cms-driven website, with no option to change the code. What I want to accomplish is creating friendly url's, using only apaches mod-rewrite engine.

The problem is I'm creating an infinite loop, because I first redirect the original url (index.php?id=21) to a friendly one (/friendly/) and then rewrite the '/friendly' part back to 'id=21'

I know there should be an extra condition or parameter to avoid looping in this case, but I can´t get one of the possible solutions to work.

Here´s the code:

RewriteCond %{query_string} ^id=21$ [NC]
RewriteRule /* /peuterspeelzaal? [R=301,L]

RewriteRule ^peuterspeelzaal$ index.php?id=21 [L]

© Stack Overflow or respective owner

Related posts about mod-rewrite

Related posts about htaccess