Zend框架重写模式css, javascript


Zend framework rewrite mode css, javascript

my hataccess:

addDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index'.php|uploads|robots'.txt|favicon'.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

my index.php in THE ROOT

define('RUNNING_FROM_ROOT', true);
include 'public/index.php';

所有的请求都重定向到index.php,然后这个index.php需要公共/index.php -所以应用程序的工作,但有一个问题是,css, javascript文件不能加载,因为他们被重定向,如何解决这个问题?

默认情况下它们应该链接到mysite.com/public/css/style.css,但它们链接到mysite.com/css/style.css -不存在

试试这样:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

在这种情况下,您只获得请求的文件(RewriteRule ^)。*$ - [NC,L])如果文件大小大于0 (RewriteCond %{REQUEST_FILENAME} -s),一个符号链接(RewriteCond %{REQUEST_FILENAME} - L)或一个目录(RewriteCond %{REQUEST_FILENAME} -d)。在所有其他情况下,重写为index.php (RewriteRule ^)。*$ index.php [NC,L])