Home » Php » No input file specified – apache and php-fastcgi

No input file specified – apache and php-fastcgi

Posted by: admin July 12, 2020 Leave a comment


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]


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.


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.

How to&Answers:

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.

I changed all routes to pass a _url parameter:

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

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.

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.

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;

Now it works fine.


Change your line with noticias:

  RewriteRule ^noticias/?$ index.php/noticias/frontend/list/ [L]


We sometimes see this on sites that use rewrites. We fixed this by changing the rewrite. The old line would be something like:

RewriteRule ^(.*)$ _routing.php/$1 [L]

We changed it into:

RewriteRule ^(.*)$ _routing.php [L]

This resolved the issue.