开发者

Apache Rewrite Excluding Assets Directory

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

actions/ templates/ site/ 开发者_如何学Python 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.


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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜