论坛首页 入门技术论坛

在.htaccess中配置rewrite后出现500错误的问题

浏览 6698 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-10-31  

之前在.htaccess中配置了rewrite后,总是会出现服务器500错误,检查过原因:

1.不是httpd.conf中没有loadModule mod_rewrite

2.也不是Directory 指令AllowOverride None的问题

3.更不是我写的.htaccess中语法的问题

 

我的.htacess是这样写的,

写道
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /rewrite
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
 

 

/rewrite/webroot这个目录已经存在了,但仍出错,查看apache error log是这样:

写道
[Fri Oct 31 10:23:01 2008] [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.
[Fri Oct 31 10:23:01 2008] [debug] core.c(3046): [client 127.0.0.1] r->uri = /rewrite/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/webroot/webroot/webroot/webroot/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/webroot/webroot/webroot/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/webroot/webroot/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/webroot/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/webroot/index.html
[Fri Oct 31 10:23:01 2008] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /rewrite/index.html
 

后来我试了试在/rewrite/webroot中也写一个.htaccess文件:

写道
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rewrite/webroot
</IfModule>

 然后居然能访问成功了,难道还需要在rewrite的各个子目录中也添加.htaccess?

虽然现在我要的功能实现了,可是还是有点迷惑,不知谁可帮我解解惑。

   发表时间:2008-10-31  
另外,如果我用url直接访问/rewrite/webroot/index.html也可以成功访问,这样有暴露文件路径的危险,我如何配置才能让用户直接访问/rewrite/webroot/时失败,而只能通过/rewrite访问呢?
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics