I've written a very simple MVC FW, so all requests are routed to index file and the index file dispatches requests to the controllers.
I have the following .htaccess:
RewriteEngine On
RewriteBase /SlotDemo
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
And it works great but for some reason it tries to route my .js files as if they were php files (tries to route them to index.php which of course causes error).
What should I add/remove to make it treat '.js' as it treats the css files?
RewriteBase
is only for redefining the URL base, not the filesystem base path - Pierre-Olivier 2012-04-03 20:48
You can easily combine both rules into one like this:
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l
# forward the URI to front controller index.php
RewriteRule ^ index.php [L]
RewriteRule ^(?!\.js).*$ index.php [L]
and see if JS file still passes through to index.php. If yes then there is some other conflicting redirect code somewhere - anubhava 2012-04-03 20:44
CSS and JavaScript files should be treated equally, check your requests for spelling errors or casing differences. (ex: jQuery.js is not the same as jquery.js)