g1smd - 9:29 pm on Jan 20, 2013 (gmt 0)
REQUEST_URI is updated to point to a different internal resource after an internal rewrite.
THE_REQUEST contains the original
GET /thisthing HTTP/1.1
HTTP request and is not changed as rewrites are processed.
You need to look at
THE_REQUEST to be sure that you're looking at what was requested by the browser, rather than as a result of a previous internal rewrite.
example.com/index.php non-canonical URL.
2. Redirect to
www.example.com/ canonical URL.
3. Internally rewrite to
/index.php internal path to fetch the content.
If you test
REQUEST_URI instead of
THE_REQUEST in (2) then when step (3) is executed, the reparse of the htaccess file will re-match the redirecting rule (htaccess is reparsed until no more rules match the current request), invoke it and expose the previously rewritten internal path back out on to the web as a new URL. Requesting
example.com/index.php will redirect to
www.example.com/ and then requesting
www.example.com/ will internally rewrite to
index.php and then immediately redirect to
www.example.com/index.php. The browser requests
www.example.com/index.php and around you go again. You've now got an infinite loop.
Apologies for the typo yesterday. The
[^ ]* should have been
[^\ ]* as Lucy pointed it.
It was well after midnight here.