mod_rewrite/htaccess重定向问题!(递归限制)


mod_rewrite/htaccess redirect issue! (recursion limit)

我正在尝试创建我的mod_rewrite文件,以便在查看文件时基本上删除所有的.php扩展名。

这是我的.htaccess:

RewriteEngine On
DirectoryIndex index.php
ErrorDocument 404 /errors/404.php
ErrorDocument 403 /errors/403.php
ErrorDocument 500 /errors/500.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

下面是我在尝试一个随机名称时从apache日志中得到的错误:

[Tue Jan 31 17:26:05 2012] [error] [client 127.0.0.1] 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 Jan 31 17:26:05 2012] [debug] core.c(3112): [client 127.0.0.1] r->uri = /aboutasdfoi.php.php.php.php.php.php.php.php.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php.php.php.php.php.php.php.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php.php.php.php.php.php.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php.php.php.php.php.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php.php.php.php.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php.php.php.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php.php.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi.php
[Tue Jan 31 17:26:05 2012] [debug] core.c(3118): [client 127.0.0.1] redirected from r->uri = /aboutasdfoi

我该怎么修理它?感谢

要隐藏.php扩展,请使用以下代码:

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^GET's.+'.php [NC]
RewriteRule ^(.+)'.php$ /$1 [R=301,L,NC]
# To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_URI} !'.php$ [NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule . %{REQUEST_URI}.php [L]