.htaccess issues: No input file specified

87,161

Solution 1

I was beating my head up against this as well. I'm also installing Code Igniter.

The goocher was no RewriteBase. Here's my .htaccess:

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

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

Solution 2

The Problem

I encountered a similar problem just now and unfortunately none of the answers in this thread helped:

Zend Framework was giving out "No input file specified.", but:

  • The default RewriteBase was just fine, and adding RewriteBase / did not help
  • It's a shared hosting server and only FastCGI is available (no ability to switch to SuPHP)
  • AcceptPathInfo was on
  • There was no problem with URL rewriting in general on the server

So the answer came from the following site: https://ellislab.com/forums/viewthread/55620/P15 [dead link] (even though the host is not DreamHost).

The Solution

Apparently all you need to do is replace this line:

RewriteRule ^(.*)$ index.php/$1

With this:

RewriteRule ^(.*)$ index.php?/$1

Problem solved.

Solution 3

This worked for me:

 <IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
 </IfModule>

After index.php, the question mark is important!

Solution 4

Try if it works with a simpler RewriteCond; like one that rewrites only everything that isn't an existing file/folder/link:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*)$ /index.php/$1 [R,L]

Solution 5

Go Daddy Users:

  1. login to your Go Daddy Account
  2. click on your hosting account.
  3. go to Settings > File Extensions Management
  4. change .php and .php5 to run under PHP5.2X (instead of PHP5.2xFastCGI)

SOLVED!!!!

Share:
87,161

Related videos on Youtube

Michal M
Author by

Michal M

Web Developer I use: OOPHP MySQL Perl JavaScript HTML5 CSS3 I'm on: twitter zerply

Updated on September 08, 2020

Comments

  • Michal M
    Michal M over 3 years

    Can someone help me with this? I'm feeling like I've been hitting my head against a wall for over 2 hrs now.

    I've got Apache 2.2.8 + PHP 5.2.6 installed on my machine and the .htaccess with the code below works fine, no errors.

    RewriteEngine on
    RewriteCond $1 !^(index\.php|css|gfx|js|swf|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    The same code on my hosting provider server gives me a 404 error code and outputs only: No input file specified. index.php is there. I know they have Apache installed (cannot find version info anywhere) and they're running PHP v5.2.8.

    I'm on Windows XP 64-bit, they're running some Linux with PHP in CGI/FastCGI mode. Can anyone suggest what could be the problem?

    PS. if that's important that's for CodeIgniter to work with friendly URLs.


    Update1:

    mod_rewrite is installed and on.

    What I've noticed is that if I change in RewriteRule to /index.php?$1 (question mark instead of forward slash) it goes into an infinite loop. Anyway, using question mark isn't an option as CodeIgniter (required) is not going to work this way.

    Homepage also works when I request index.php directly: example.com/index.php

    I'm starting to think it might be apache thinking that once the trailing slash is added it is not a file anymore but a folder. how to change such a behaviour?


    Update 2:

    I was wrong.
    Apache handles these URLs correctly.
    Requesting http://example.com/index.php/start/ (homepage) or any other valid address works.
    Seems that Apache is just not forwarding the query for some reason.


    Update 3:

    Just to be clear what I'm trying to achieve.
    I want to rewrite addresses like that:

    http://www.example.com/something/ => http://www.example.com/index.php/something/ http://www.example.com/something/else/ => http://www.example.com/index.php/something/else/

  • Michal M
    Michal M over 14 years
    No. mod_rewrite is on. What I've noticed is that if I change in RewriteRule to /index.php?$1 (question mark instead of forward slash) it goes into an infinite loop. homepage also works when I request index.php directly: example.com/index.php I'm starting to think it might be apache thinking that once the trailing slash is added it is not a file anymore but a folder. how to change such a behaviour?
  • Michal M
    Michal M over 14 years
    using ? mark isn't an option. CodeIgniter won't work this way.
  • Michal M
    Michal M over 14 years
    Re your edit. That's the point of not having $ at the end. So that any URLs starting with what's in the brackets are not being rewritten to index.php (inc. index.php and index.php/anything/) otherwise it will not work.
  • Michal M
    Michal M over 14 years
    this works for the homepage: example.com/, not for anything else like example.com/something/
  • Michal M
    Michal M over 14 years
    Btw. I asked at SeverFault. not much luck there either and less answers/ideas.
  • kkyy
    kkyy over 14 years
    Oh, now I get it... you want to REDIRECT the requests instead of just REWRITING... (if I understood your update #3 correctly :) Try adding [R] into the end of the rewriterule, see my updated answer.
  • Vicky
    Vicky over 8 years
    another problem you have created if you are using this function basename=$_SERVER['PHP_SELF']; which return only index.php
  • Bradmage
    Bradmage about 8 years
    This was the fix for my base installation of ispconfig 3. Worked fine on wamp server.
  • Danon
    Danon about 7 years
    I don't know why, but this worked perfectly for me :)
  • Joey Harwood
    Joey Harwood over 6 years
    The .htaccess for the live server is unchanged from the accepted answer. If there's a good reason to provide a different explanation for the Localhost you should elaborate on that.
  • Gladen
    Gladen about 6 years
    Question mark fixed it for me with getting my site to work on ISPConfig.