2012-11-08 207 views
1

我有一個.htaccess文件。內容是:.htaccess內部服務器錯誤500

<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

回答

4

這是因爲這行:

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

重寫引擎一直循環到URI停止變化,而且(.*)模式匹配一切,包括webroot/whatever。嘗試在它前面添加一個條件:

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