No input file specified - apache and php-fastcgi

My client site is currently running on apache server with mod_php. All application routes are defined in the .htaccess file (see code below). Now he is trying to switch to the server with apache and php-fastcgi, but the routes do not work for long.

<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> 

When I access http: //domain.tld/noticias , I get No input file specified and in 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 directly access the route http: //domain.tld/index.php/noticias/frontend/list/ it works fine.

UPDATE

I found a working solution that changes part of the structure behavior. If someone has a solution without having to change the structure (perhaps in the apache or php configuration), I will be happy to award a response to the award.

+8
php apache .htaccess
source share
3 answers

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

I changed all routes to pass the _url parameter:

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

Thus, I would not get the "No input file defined" error, but the infrastructure (zend) did not recognize the route and always showed the home page.

The route manager expected the $requestUri variable to be in the format index.php/module/controller/action , but with the change .htaccess it was index.php?_url=/module/controller/action . So I had to make some changes to the Zend_Controller_Request_Http class, so it will do 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 great.

+5
source share

Change your line to noticias :

  RewriteRule ^noticias/?$ index.php/noticias/frontend/list/ [L] 
+2
source share

We sometimes see this on sites that use rewriting. We fixed this by changing the rewriting. The old line will look something like this:

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

We changed it to:

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

This solved the problem.

+1
source share

All Articles