2013-05-13 143 views
0

我正在尝试将example.com/test重写为example.com/pages/test.php(依此类推)。URL重写失败:内部重定向

我做了这样的代码:

RewriteEngine on 
RewriteRule ^(.*) /pages/$1.php 

这不起作用:阿帕奇给我这个错误:

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.

我不知道如何去。

回答

1

Apache是​​重写/test/pages/test.php,然后试图将它改写为/pages/pages/test.php.php,然后/pages/pages/pages/test.php.php.php等等...

添加[L]标志停止后的第一个改写。

一般情况下,你也想一对夫妇的重写条件如下,以防止你实际上并不想重写改写(图片,脚本等):

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*) /pages/$1.php [L] 
+0

它的工作原理相同的错误。谢谢! – Hedam 2013-05-13 13:59:39

0

这是循环。尝试在RewriteRule的末尾添加[L]。

+0

相同的结果。仍然在日志文件 – Hedam 2013-05-13 13:32:47