我有一个简单的.htaccess,由于某种原因无法正确redirect:
RewriteEngine on RewriteBase / RewriteRule ^.*$ /test.php [L]
有一个日志条目:
[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
有我想要访问的URL是/ blabla
它似乎重写正确,但[L]选项莫名其妙无效。 怎么可能?
虚拟主机是这样configuration的:
<VirtualHost *:80> ServerName www.mx-key.ru ServerAlias mx-key.ru www.mx-key.ru ServerAdmin [email protected] 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>
您还需要指定RewriteCond – 您的RewriteRule总是匹配所有内容(因为^.*$ )。 看看这里:
您需要排除RewriteRule的目标,即/test.php 。
像这样的东西应该工作:
RewriteCond %{REQUEST_URI} !^/test.php$
其中提到“只有在请求URI不以/test.php开头时才重写”。