Forum Moderators: phranque
I read some posts about this problem in this forum, but I can't work out what is wrong in my settings.
On my server (Debian Etch-Apache2.2.3), here's my .htaccess
RewriteEngine On
RewriteBase /example/
ErrorDocument 404 /example/index.php?option=com_404
RewriteRule ^((fr¦de¦en)\/(.*\.html)?)$ index.php?$1 [L,NC]
It translates
/example/fr/shop/article1.html
into
/example/index.php?fr/shop/article1.html
The real parameters rewriting is in a php process
All is working fine except :
On my first access to the site, the only valid adresses are
1. /example/
2. /example/fr/ (ou ../en/ ou ../de)
All others adresses generates an 'error in redirection'
But once i use one of these valid addresses, i can navigate thru all site adresses (even those which bugged before),
After a while without browsing thru the site, the problem happens again
In rewrite_log, the following sequence goes in an endless loop with IE and in a 20 steps loop with FF
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (3) [perdir /var/www/example/] add path info postfix: /var/www/example/fr -> /var/www/example/fr/shop/order_details-10.html
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (3) [perdir /var/www/example/] strip per-dir prefix: /var/www/example/fr/shop/order_details-10.html -> fr/shop/order_details-10.html
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (3) [perdir /var/www/example/] applying pattern '^((fr¦de¦en)\/(.*\.html)?)$' to uri 'fr/shop/order_details-10.html'
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (2) [perdir /var/www/example/] rewrite 'fr/shop/order_details-10.html' -> 'index.php?fr/shop/order_details-10.html'
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (3) split uri=index.php?fr/shop/order_details-10.html -> uri=index.php, args=fr/shop/order_details-10.html
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (3) [perdir /var/www/example/] add per-dir prefix: index.php -> /var/www/example/index.php
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (2) [perdir /var/www/example/] trying to replace prefix /var/www/example/ with /example/
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (1) [perdir /var/www/example/] internal redirect with /example/index.php [INTERNAL REDIRECT]
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8d5e18/initial/redir#1] (3) [perdir /var/www/example/] strip per-dir prefix: /var/www/example/index.php -> index.php
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8d5e18/initial/redir#1] (3) [perdir /var/www/example/] applying pattern '^((fr¦de¦en)\/(.*\.html)?)$' to uri 'index.php'
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8d5e18/initial/redir#1] (1) [perdir /var/www/example/] pass through /var/www/example/index.php
Where is my mistake ?
Thanks for your answer
[edited by: jdMorgan at 2:11 pm (utc) on Mar. 12, 2008]
[edit reason] use example.com, fix character-entities [/edit]
RewriteRule ^((fr¦de¦en)\/(.*\.html)?)$ index.php?$1 [L,NC]
Note that forward slashes need not be escaped in mod_rewrite; This is only required in PERL, PHP, or other languages which use slahses to denote regular expressions, as in "/regex-here/".
So you can write your rule as:
RewriteRule ^((fr¦de¦en)/(.*\.html)?)$ index.php?$1 [L,NC]
RewriteRule ^((fr¦de¦en)/([^.]+\.html)?)$ /index.php?$1 [L,NC]
It is likely that the looping is occurring because of a problem in your script. Further note that if there was a problem, your code would cause an *internal* loop, because it invokes an internal redirection, not an external redirect. Therefore, the fact that the looping is 'visible' to Firefox and IE indicates that the problem lies outside this code, or in an unexpected interaction between this code and your script.
Look at your access logs to see what happened after the events shown in the RewriteLog above. I suspect you may see something odd about the subsequent requests -- and the 301 or 302 server status codes will be easy to examine with a server header checker, such as the "Live HTTP Headers" add-on for Firefox/Mozilla browsers.
Jim
Sure, i paste only one full sequence but after
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8d5e18/initial/redir#1] (1) [perdir /var/www/example/] pass through /var/www/example/index.php
it starts again in
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (3) [perdir /var/www/example/] add path info postfix: /var/www/example/fr -> /var/www/example/fr/shop/order_details-10.html
192.168.1.1 - example [12/Mar/2008:10:12:46 +0100] [test.aude-line.com/sid#6718d8][rid#8cae38/initial] (3) [perdir /var/www/example/] strip per-dir prefix: /var/www/example/fr/shop/order_details-10.html -> fr/shop/order_details-10.html
In my script there's no redirection.
I only analyse the $_SERVER['QUERY_STRING'] to set the post and get parameters and rewrite the $_SERVER['QUERY_STRING']
But the problem never reaches my php process !
In LiveHTTP headers, i've got no information
In acces.log : (only 2 of many repeated lines)
192.168.1.1 - - [11/Mar/2008:11:29:50 +0100] "GET /example/fr/shop/details_order-13.html HTTP/1.1" 401 561 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12"
192.168.1.1 - example[11/Mar/2008:11:30:04 +0100] "GET /example/fr/shop/details_order-13.html HTTP/1.1" 301 26 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12"
Thanks for your help
PS : this time i paste UTF8 codes, hopping this will be better
This must have been done by another agent: A different RewriteRule (perhaps in a subdirectory), a script, a mod_alias directive, etc.
Jim