Forcing mod_write to not rewrite anything ending in .css or .js
I have a very simple rewrite rule. It basically takes everything and sends it to index.php.
That rule works, but as you can guess any request to an image, css file, or js file gets redirected also to the php page. So i tried adding conditions, but they dont work at all:
RewriteCond %{REQUEST_FILENAME} !(^.*css$)
RewriteCond %{REQUEST_FILENAME} !(^.*js$)
I would except this t开发者_运维百科o mean do the rewrite rule unless the filename ends in .css or .js so that I can get the actual JS file and not a php page instead.
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php
It's from the Zend Framework documentation, and unless I'm missing a step, it should work quite well.
精彩评论