I am trying to introduce nice urls:
RewriteRule ^(.*).html$ index.php?arianne_url=content/$1 [L]
And i want to externally rewrite access to the old style urls:
RewriteCond %{QUERY_STRING} arianne_url=content/([^&]*)
RewriteRule ^.* /%1.html? [R=301]
The problem is that this ends in an endless loop.
I tried to define env and check it, but this still results in an endless loop
RewriteRule ^(.*).html$ index.php?arianne_url=content/$1 [L,env=arianne:rewrite]
RewriteCond %{env:arianne} ^$
RewriteCond %{QUERY_STRING} arianne_url=content/([^&]*)
RewriteRule .* /%1.html? [R=301]
I have to do this in .htaccess as I don't have access to the server configuration files.
Edit:
Logfile: http://pastebin.ca/1927769
# enable nice urls
RewriteRule ^(.*).html$ index.php?arianne_url=content/$1 [L,env=arianne:rewrite]
# Redirect old style request to new nice url
RewriteCond %{env:arianne} ^$
RewriteCond %{QUERY_STRING} arianne_url=content/([^&]*)
RewriteRule ^.* /%1.html? [R=301,L]
Best Answer
Have you tried adding 'L' (last) to your RewriteRule? i.e.,
This will mark the rule as being the last rule, and is essentially equivalent to a break statement in C. Once this rule is executed, it will stop matching rules.
Could that be the reason?
Andrew