没有指定输入文件 - apache和php-fastcgi

Luc*_*ira 8 php apache .htaccess

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

<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>
Run Code Online (Sandbox Code Playgroud)

当我访问http://domain.tld/noticias时,我得到了No input file specified,并且在apache error_log中[fcgid:warn] mod_fcgid: stderr: PHP Warning: Unknown: function '1' not found or invalid function name in Unknown on line 0,但如果我直接访问路由http://domain.tld/index.php/noticias/frontend/list/它工作正常.

UPDATE

我找到了一个改变一些框架行为的工作解决方案.如果某人有一个解决方案而不必更改框架(可能是在apache或php配置中),我会慷慨地给予奖励答案.

Luc*_*ira 5

由@ user3584460消化,我决定更改所有路由以将所需的控制器/操作作为查询字符串参数传递.它是如何完成的.

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

RewriteRule "^noticias/?$" index.php?_url=/noticias/frontend/list/ [L,QSA]
Run Code Online (Sandbox Code Playgroud)

这样我就不会得到错误"没有指定输入文件",但框架(zend)不会识别路由,并且总是会显示主页.

路由调度程序期望$requestUri变量采用格式index.php/module/controller/action,但随着变化.htaccess,它就是index.php?_url=/module/controller/action.所以我不得不在Zend_Controller_Request_Http课堂上做一些改动,所以它会进行转换.

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

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;
}
Run Code Online (Sandbox Code Playgroud)

现在它工作正常.