Apache开启伪静态后报500错误.

参考:http://blog.163.com/lgh_2002/blog/static/44017526201051452939761/

加载Rewrite模块:

在conf目录下httpd.conf中找到

LoadModule rewrite_module modules/mod_rewrite.so

这句,去掉前边的注释符号“#”,或添加这句。

允许在任何目录 或者特定目录中使用“.htaccess”文件,将“AllowOverride”改成“All”(默认为“None”)

<Directory "F:\www">

AllowOverride All

</Directory>

在Windows系统下不能直接建立“.htaccess”文件,可以在命令行下使用“echo a> .htaccess”建立,然后使用记事本编辑。

检查APACHE日志发现如下信息:

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个链接。怀疑是rewrite模块规则写错了,进入死循环。突然想起了.htaccess文件, 原来这个站点是测试部署在一个子目录/XXXX下,而.htaccess是直接从另一个网站拷贝过来的

RewriteEngine On

RewriteBase /kohana/

RewriteRule ^(application|modules|system) - [F,L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]

解决方法:将红色部分代码改成如下

RewriteRule ^(.*)$ /index.php/$1 [PT,L]