.htaccess内部服务器错误500

时间:2012-11-08 15:20:34

标签: .htaccess internal-server-error

我有一个.htaccess文件。内容是:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule (.*\.(png|gif|jpg|jpeg|js|css|swf))$ webroot/img_handler.php?arg=$1 [L] 
   RewriteRule    ^$ webroot/    [L]
   RewriteRule    (.*) webroot/$1 [L]
</IfModule>
# test 5

# disable directory browsing -IMPORTANT, do NOT remove.
Options -Indexes

# protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>

# disable the server signature
ServerSignature Off


# protect php.ini
<files *.ini>
order allow,deny
deny from all
</files>

这是导致内部服务器错误,问题是什么?

THX: pixeles

1 个答案:

答案 0 :(得分:4)

这是因为这一行:

RewriteRule    (.*) webroot/$1 [L]

重写引擎循环,直到URI停止更改,(.*)模式匹配所有内容,包括webroot/whatever。尝试在它前面添加一个条件:

RewriteCond %{REQUEST_URI} !webroot
RewriteRule    (.*) webroot/$1 [L]