我正试图将我的Phalcon应用程序的前端切换到AngularJS。但我在.htaccess
文件上遇到了一些麻烦。以下是我目前的记录。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/.* api/index.php [L,QSA]
RewriteCond $1 !^(api)
RewriteRule ^(.*)$ public/index.php?_url=/$1 [QSA,L]
它路由到Phalcon,但所有的.css
和.js
文件在公共文件夹现在抛出一个404
。我哪里做错了?
如果你想忽略文件和目录,你需要在你的。htaccess中添加额外的重写规则。如果您也想忽略扩展,还有另一个重写规则。https://stackoverflow.com/a/17029882会给你所需的信息。
RewriteCond %{REQUEST_URI} !(.css|.js|.png|.jpg|.gif)$ [NC]
就足够了,在大多数情况下,文件和目录也不会被这样重写:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d