Hi,
I’m trying to get my head around mod_rewrite and have a problem I could not fined the answer to on the net or in the book: “The Definitive Guide to Apache mod_rewrite”.
I have a the following dir and file setup:
Site root
- .htaccess
- Public
- index.php
content of the “.htaccess” file:
RewriteEngine on
RewriteRule ^$ Public/ [L]
RewriteRule ^(.*)$ Public/$1 [L]
root URL is: localhost/mod_rewrite_test/ (for instant.)
If I hit “localhost/mod_rewrite_test/” in the browser i get a “500 Internal Server Error” on my screen.
The error log tells me:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
That tells me that I have a infinity loop of some kind.
Further information indicate that “/Public” is added on top of it self, like this:
/mod_rewrite_test/Public/Public/Public/Public/Public/Public/Public/Public/Public/Public/
However, if I put a “.htaccess” file in the “Public” folder with the following content it works as intended:
RewriteEngine on
And the rewrite log give the following information:
(2) init rewrite engine with requested uri /mod_rewrite_test/index.php
(1) pass through /mod_rewrite_test/index.php
(3) [perdir C:/xampp/htdocs/mod_rewrite_test/] strip per-dir prefix: C:/xampp/htdocs/mod_rewrite_test/index.php -> index.php
(3) [perdir C:/xampp/htdocs/mod_rewrite_test/] applying pattern '^$' to uri 'index.php'
(3) [perdir C:/xampp/htdocs/mod_rewrite_test/] strip per-dir prefix: C:/xampp/htdocs/mod_rewrite_test/index.php -> index.php
(3) [perdir C:/xampp/htdocs/mod_rewrite_test/] applying pattern '(.*)' to uri 'index.php'
(2) [perdir C:/xampp/htdocs/mod_rewrite_test/] rewrite 'index.php' -> 'Public/index.php'
(3) [perdir C:/xampp/htdocs/mod_rewrite_test/] add per-dir prefix: Public/index.php -> C:/xampp/htdocs/mod_rewrite_test/Public/index.php
(2) [perdir C:/xampp/htdocs/mod_rewrite_test/] strip document_root prefix: C:/xampp/htdocs/mod_rewrite_test/Public/index.php -> /mod_rewrite_test/Public/index.php
(1) [perdir C:/xampp/htdocs/mod_rewrite_test/] internal redirect with /mod_rewrite_test/Public/index.php [INTERNAL REDIRECT]
(2) init rewrite engine with requested uri /mod_rewrite_test/Public/index.php
(1) pass through /mod_rewrite_test/Public/index.php
(1) [perdir C:/xampp/htdocs/mod_rewrite_test/Public/] pass through C:/xampp/htdocs/mod_rewrite_test/Public/index.php
Way do it work now? I can’t figure it out.
I use ApacheFriends XAMPP version 1.7.7 on Windows 7.
Hope anybody have the time to help me understand this, it would be very much appreciated.