Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a simple .htaccess which fails to redirect correctly on some reason:

RewriteEngine on
RewriteBase /
RewriteRule ^.*$ /test.php [L]

There is a log entry:

[Tue Nov 16 17:04:12 2010] [error] [client 213.141.155.85] 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.
[Tue Nov 16 17:04:12 2010] [debug] core.c(3053): [client 213.141.155.85] r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /test.php
[Tue Nov 16 17:04:12 2010] [debug] core.c(3059): [client 213.141.155.85] redirected from r->uri = /blabla

There URL i'm trying to access is /blabla

It seems to rewrite correctly, but [L] option somehow has no effect. How can that be?

virtual host is configured like this:

<VirtualHost *:80>
ServerName www.mx-key.ru
ServerAlias mx-key.ru www.mx-key.ru
ServerAdmin FractalizeR@yandex.ru
DocumentRoot /home/mxkey/mx-key.ru/www
DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml
ErrorLog /home/mxkey/mx-key.ru/logs/httpd_error.log
CustomLog /home/mxkey/mx-key.ru/logs/httpd_access.log "%v %h %l %u %t \"%r\" %>s %b"
LogLevel Debug
<IfModule mod_fastcgi.c>
        Options +ExecCGI
        FastCgiExternalServer /home/mxkey/mx-key.ru/www/php-fpm.handler -socket /home/mxkey/php-fpm.sock -idle-timeout 600
        AddType application/x-httpd-fastphp5 .php
        Action application/x-httpd-fastphp5 /php-fpm.handler
</IfModule>
</VirtualHost>
share|improve this question
    
If I add RewriteCond %{REQUEST_URI} !^/php-fpm.handler to the .htaccess it starts to work fine. Any way to avoid it? –  FractalizeR Nov 17 '10 at 8:24
add comment

1 Answer

up vote 1 down vote accepted

You need to specify RewriteCond also - your RewriteRule is always matching everything (because of ^.*$). Take a look here:

You need to exclude the target of RewriteRule, which is /test.php.

Something like this should work:

RewriteCond %{REQUEST_URI} !^/test.php$

which says something like "rewrite only if the request URI doesn't start with /test.php".

share|improve this answer
    
Somehow it doesn't work. I even tried RewriteCond {REQUEST_URI} !\.php$ but it also doesn't work somehow. –  FractalizeR Nov 16 '10 at 14:54
1  
Sorry, I've been missing % - you need %{REQUEST_URI}. –  icyrock.com Nov 16 '10 at 14:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.