我已经写了一个非常简单的MVC FW,所以所有的请求都被路由到索引文件,索引文件将请求分派到控制器。
我有以下.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]而且它工作得很好,但是出于某些原因,它试图将我的.js文件当作php文件来路由(尝试将它们路由到index.php,这当然会导致错误)。
我应该添加/删除什么来让它像对待css文件一样对待'.js‘?
发布于 2012-04-04 03:37:20
您可以轻松地将这两个规则合并为一个规则,如下所示:
# 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]发布于 2012-04-04 03:59:16
CSS和JavaScript文件应该一视同仁,检查您的请求是否存在拼写错误或大小写差异。(例如: jQuery.js与jquery.js不同)
https://stackoverflow.com/questions/10000049
复制相似问题