本文介绍了Nginx上的Zend框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用的基于Zend Framework的站点现在正在迁移到其生产服务器.该服务器原来是nginx(惊奇!).自然,该站点无法正常运行,因为它是在Apache上开发的,并且依赖于htaccess文件.

The Zend Framework based site I have been working on is now being migrated to its production server. This server turns out to be nginx (surprise!). Naturally the site does not work correctly as it was developed on Apache and relies on an htaccess file.

我的问题是……有人对此有任何经验吗?关于如何将htaccess文件的内容转换为nginx.conf文件的任何想法?我正在对此进行研究,但希望有人对此有所经验.谢谢!

My question is... anyone have any experience with this? Any ideas on how to translate what the htaccess file does to an nginx.conf file? I'm researching this but am hoping someone already has experience with this. Thanks!

这是当前的htaccess:

This is the current htaccess:

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

推荐答案

我知道这是一个非常老的线程,但是无论如何它可能会对某些人有所帮助.

I know it's a pretty old thread but it might help some people anyway.

基本上,它将任何404错误重定向到index.php,但是如果该文件存在(类型文件),它将设置正确的根目录.

Basically it redirects any 404 error to index.php, but if the file exists (type file) it will set the right root.

我从头顶上做到了.它可能不会立即起作用,您必须放置正确的路径和fastcgi配置.我还把所有内容都放回了index.php,因为它应该可以与Zend_Framework一起工作

I did it from the top of my head. It might not be working right away, and you have to put the right path and fastcgi config. I also put everything back to index.php as it should work like that with Zend_Framework

error_page  404 = /index.php;

location / {
    if (-f $request_filename) {
        root   /var/www;
    }
}

location ~ \.php$ {
        fastcgi_pass   unix:/tmp/php.sock;
        fastcgi_index  index.php;

        fastcgi_param  SCRIPT_FILENAME     /var/www/index.php;
        include /etc/nginx/fastcgi_params;
}

这篇关于Nginx上的Zend框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 06:12