Search code examples
iisurl-rewritingiirf

Trying to exclude css and js files with IIRF rewrite


I'm trying to get IIRF working so that it rewrites certain URLs, but ignores files like .css and .js files.

I have URLs like:

/admin/
/admin/user/
/admin/user/view-details/1
/admin/user/view-details/1?edit

Which all work, but I can't seem to get this to work:

/admin/_assets/css/admin.css

My .ini file looks like this:

RewriteRule /admin/([^/]+)/([^/]+)/([^/]+)\?edit$ /admin/index.php?edit&action=$1&sub-action=$2&id=$3 [L,I,QSA]
RewriteRule /admin/([^/]+)/([^/]+)/([^/]+)$ /admin/index.php?edit&action=$1&sub-action=$2&id=$3 [L,I,QSA]
RewriteRule /admin/([^/]+)/$ /admin/index.php?action=$1 [L,I,QSA]
RewriteRule ^/admin/(.*)$ - [L]

I've also tried:

RewriteRule (.+\.)(php|jpg|png|jpeg|gif|ttf|sql|txt|htm|zip|css)$ - [L]

The things I've tried give either a blank document when I navigate directly to the css file, or I get:

HTTP Error 404.4 - Not Found
The resource you are looking for does not have a handler associated with it.

I don't have much experience with IIRF or IIS, so I'm a bit stuck with what to try next. Am I looking in the wrong place? Or have I made a really basic mistake?

Thanks


Solution

  • I've managed to fix this by adding:

    RewriteRule /admin/_assets/(.+)$ /admin/_assets/$1 [L,I,QSA]
    

    to the top of my file. I'm still not sure why nothing is being logged, but this fixed it for my needs.