Apache Rewrite excluding asset directory

I am writing a mini-MVC application. Application architecture:

actions / templates / site / app / styles / images / scripts /

So far, I have a controller that is working correctly, accepting all requests. However, javascript files are not displayed as expected in the browser; I get 404 Not Found when I try to download a file in the browser.

Here is my current directory in the vhost file:

<Directory "/path/to/apps/ecatalogue">
DirectoryIndex index.php
RewriteEngine On
RewriteBase /apps/ecatalogue
RewriteRule ^scripts/(.*) - [NC,L] <--- Rule not working
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [NC,L,QSA]
</Directory>

      

I can confirm that everything else works; I just need apache to ignore anything in the scripts, so the file can be loaded normally without processing the controller.

Your help is appreciated.

Update I: Added directory tag to complete.

+2


a source to share


1 answer


I've switched a few things here - this is based on the rewrite rules I use for almost every MVC application I run. It comes from some of the guidelines from the Zend Framework documentation.



DirectoryIndex index.php

RewriteEngine On
RewriteBase /apps/ecatalogue

# If it a file/directory/symlink, serve it.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^.*$ - [NC,L]

# Otherwise let go MVC
RewriteRule ^.*$ index.php [NC,L]

      

+4


a source







All Articles