views:

50

answers:

1

Hi all

I'm writing a mini-MVC application. App architecture:

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

So far, I've got a controller working properly, taking in all requests. However, javascript files are not being rendered properly in the browser; I'm getting a 404 Not Found when I try to load the file in the browser.

Here is my current Directory config in a 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 everything else works; I just need apache to ignore anything in scripts so the file can be loaded normally without being processed by the controller.

Your help is appreciated.

Update I: Added Directory tag for sake of completion.

+1  A: 

I switched a couple of things around here-- this is based on the Rewrite rules I use for pretty much every MVC app I run. It comes from some recommendations from the Zend Framework documentation.

DirectoryIndex index.php

RewriteEngine On
RewriteBase /apps/ecatalogue

# If it's 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's go MVC
RewriteRule ^.*$ index.php [NC,L]
awgy
hi awgy, thanks a lot for your response. put this into a new vhost conf. it's now no longer giving me the 404 error when I try to access the JS file, but rather gives me the generic MVC error page that I set up.
Midiane
thanks awgy, got it to work in the end
Midiane