未指定输入文件-Apache和php-fastcgi [英] No input file specified - apache and php-fastcgi

查看:140
本文介绍了未指定输入文件-Apache和php-fastcgi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户的网站当前正在使用mod_php的apache服务器上运行。所有应用程序的路由都在.htaccess文件中定义(请参见下面的代码)。现在,他正在尝试迁移到运行apache和php-fastcgi的服务器,但是路由不再起作用。

My client's website is currently running on a apache server with mod_php. All application's routes are defined in the .htaccess file (see the code below). Now he is trying to migrate to an server running apache and php-fastcgi, but the routes are no long working.

<IfModule mod_rewrite.c>

  RewriteEngine On

  # Redirect
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} -s [OR]
  RewriteCond %{REQUEST_FILENAME} -l [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^.*$ - [NC,L]
  RewriteRule "^noticias/?$" index.php/noticias/frontend/list/ [L,QSA]
  RewriteRule ^.*$ index.php [NC,L]

</IfModule>

当我访问 http: //domain.tld/noticias ,我得到未指定输入文件,并在apache error_log [fcgid:warn] mod_fcgid中: stderr:PHP警告:未知:未找到函数'1'或在行0的未知中函数名称无效,但是如果我直接访问路由 http://domain.tld/index.php/noticias/frontend/list/ 正常。

When I access http://domain.tld/noticias, I get No input file specified, and in the apache error_log [fcgid:warn] mod_fcgid: stderr: PHP Warning: Unknown: function '1' not found or invalid function name in Unknown on line 0, but if I access the route directly http://domain.tld/index.php/noticias/frontend/list/ it works fine.

更新

我找到了一个可行的解决方案,可以更改某些框架行为。如果某人有解决方案而不必更改框架(可能是在apache或php配置中),我将很高兴地将答案授予赏金。

I found a working solution changing some of the framework behaviour. If someone has a solution without having to change the framework (probably in the apache or php configuration), I will gadly award the answer the bounty.

推荐答案

正如@ user3584460所暗示的那样,我决定更改我的所有路由,以将所需的控制器/操作作为querystring参数传递。

As sugested by @user3584460, I decided to change all my routes to pass the desired controller/action as a querystring parameter. Here how it was done.

我更改了所有路由以传递_url参数:

I changed all routes to pass a _url parameter:

RewriteRule "^noticias/?$" index.php?_url=/noticias/frontend/list/ [L,QSA]

这样,我不会收到错误未指定输入文件,但是框架(zend)无法识别路由,并且始终显示主页。

This way I would not get the error "No input file specified", but the framework (zend) would not recognize the route, and would always show the homepage.

路由调度程序期望 $ requestUri 变量的格式为 index.php / module / controller / action ,但是随着 .htaccess 的更改,它是 index.php?_url = / module / controller / action 。因此,我必须在 Zend_Controller_Request_Http 类中进行一些更改,这样才能进行转换。

The route dispatcher expected the $requestUri variable to be in the format index.php/module/controller/action, but with the change in the .htaccess, it was index.php?_url=/module/controller/action. So I had to make some changes in the Zend_Controller_Request_Http class, so it would make the conversion.

所以我添加了 setRequestUri 方法的以下几行:

So I added the following lines to the setRequestUri method:

public function setRequestUri($requestUri = null)
{
    // ...

    // begin changes
    preg_match('/_url=([a-zA-Z0-9\/\-_\.]+)&?(.*)/', $requestUri, $matches);
    if (count($matches) == 3)
        $requestUri = '/index.php' . $matches[1] . '?' . $matches[2];
    // end changes

    $this->_requestUri = $requestUri;
    return $this;
}

现在可以正常使用了。

这篇关于未指定输入文件-Apache和php-fastcgi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆