Rewrite Cond.


Yii will call SiteController to display an 404 error if my site have some broken images or missing files (robot.txt etc.)

It is quite expensive loading while the site <img src="brokenimg.jpg">

because brokenimg.jpg will call SiteController/error function again to load the page out.

I have edit my .htaccess file with no luck.

Options +FollowSymLinks

IndexIgnore */*

RewriteEngine on

# Make backend accessible via url: http://site/backend.

RewriteRule ^backend backend.php

# If a directory or a file exists, use it directly.

RewriteCond %{REQUEST_FILENAME} \.(js|ico|gif|jpg|png|css|pdf|doc)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise forward it to index.php.

RewriteRule . index.php

I don’t want the broken files can call Yii framework.

Would you help me to solve the problem? Thanks~! :)

This would redirect all images to index.php and you loose all QUERY_STRING.

Take a look at the Rewrite Guide for handling broken links and stopping redirect loops.

You need to add a "!" to invert the rule. This is what i use:

RewriteCond %{REQUEST_URI} !\.(asp|css|dll|gif|ico|jpg|jpeg|js|png|swf|xml)$