Folder-specific RewriteRule


I’m trying to accomplish the following.

I have a .htaccess file that looks like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?request=$1 [L,QSA]

But I need something else and I can’t seem to find the solution.

I have to folders in my root directory; public and mvc, where mvc contains a framework.
public will contain images/javascript and css files in the folders img, js and css.

I want to be able to use the tag

<img src="public/images/test.png">

This works fine if I’m at the homepage http://domain/ but when I’m at http://domain/test/ it doesn’t.

I want this to work for everything that must come from within the public folder.
(only files, no directories, so I can still use http://domain/public/ as an address)

Thank you very much in advance,


What you’re referring to is using the same relative link from different directory levels. You can’t get there from here. For what you’re asking, you need to change your link to an absolute link (either external with http://yadda-yadda or internal with /yadda).



Thanks DK for your reply.

I get it, was hoping it would work :wink: