我有一个Zend Framework项目,在根目录有一个 .htaccess 文件,内容如下:
php_flag display_errors Off
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
在apache下正常运行,可是换到nginx+php-fpm下就不行了,直接就404 Not Found了,日志显示是index.php没有找到的错误
我也试了在nginx配置文件中添加rewrite规则,根据上面.htaccess文件转换过来的规则是
rewrite /!.(js|ico|gif|jpg|png|css)$ /index.php;
但是没有用,貌似rewrite只能实现RewriteRule的功能,"RewriteEngine on"怎么办,没有那句也不行
我问题就是nginx如何实现上面 .htaccess 文件的功能?
nginx.conf文件
location /
{if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php last;
}
}