Is there a better way to do this Apache rewrite?

A long time ago, someone on these forums showed me a way to do this without listing every file extension that I wanted to exclude from being sent to index.php. I can’t for the life of me remember what they told me. Searching back through my old posts didn’t turn up the answer either. Any suggestions? Thanks!

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !.(css|jpg|gif|js|ico|png|txt|html|htm|svg|rss|xml|xsl)
RewriteRule . /index.php

I tried the following, but it will send a request for a non-existent file to index.php. For example, /styles/nonexistent.css will cause an error in index.php because there’s no such controller as “styles” in the MVC.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]

You should have a 404 catch-all route defined in any case - what if someone requests a non-existent php file?

How would you do a 404 catch-all in Apache that prevents the bad request from getting sent to index.php in the first place? That’s basically the requirement.

Now that I think about it, it seems that the person who told me this line isn’t necessary didn’t consider this scenario. I mean, Apache couldn’t possibly know in advance whether or not the MVC can handle a given request.

RewriteCond %{REQUEST_FILENAME} !.(css|jpg|gif|js|ico|png|txt|html|htm|svg|rss|xml|xsl)

So it appears this entire line of questioning is pointless. Sorry.