Manny Manny - 1 year ago 71
Apache Configuration Question

How to create rewrite rule that allows to rewrite something right after slash with exceptions

i want to create these rewrite rules:



But I also need to use images and some other files and also other PHP files.

The .htaccess i have:

RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.css)$
RewriteRule ^(.*)$ index.php?site=$1 [QSA]

The problem is when i try to load file like this:

It doesn't work, because i don't know how to avoid rewriting PHP files.

Answer Source

Try this Rule,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?site=$1 [QSA]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download