I have an .htaccess file. The content is:
<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>
and this is cause an internal server error, what's the problem?
thx: pixeles
It's because of this line:
RewriteRule (.*) webroot/$1 [L]
The rewrite engine loops until the URI stops changing, and the (.*)
pattern is matching everything, including webroot/whatever
. Try adding a condition in front of it:
RewriteCond %{REQUEST_URI} !webroot
RewriteRule (.*) webroot/$1 [L]