Apache rewrite engine

Hi all,

I would like to make .htaccess rewrite requests to /images/. What i want it to do is to check if the file exists as /images/bla bla, and if not, then check ../images/bla bla. I thought i could just do something like:




RewriteEngine on

RewriteBase /


RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule ^(images|js)/(.*)$ ../$1/$2 [L]

RewriteRule . index.php [L]



But that doesn’t seems to work. In fact, none of the files work after this. The only thing which works is the actual pages (controllers and other internal things).

Thanks in advance.

You can put another .htaccess into the images folder and make the needed checks from there. I think that should work.

I’ve tried that too, but it never gets invoked.




RewriteEngine on

RewriteBase /


RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule ^(.*)$ http://www.example.com/images/$1 [L,R=301] 



Something like this maybe? Untested.

Try this:




Options +FollowSymLinks

Options -Indexes

DirectoryIndex index.php

RewriteEngine on

RewriteCond $1 !^(index\.php|images|js|robots\.txt)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L,QSA]



Sry, doesn’t work :(

Is mod_rewrite.so enabled in your httpd.conf file?

Yes, I’ve already done a lot of rewriting.

Did you restart your server after having enabled mod_rewrite? It is something i myself forget from time to time.

You can also enable a debug log for mod_rewrite. Helps with tough issues:

http://www.latenightpc.com/blog/archives/2007/09/05/a-couple-ways-to-debug-mod_rewrite