‘No input file specified’ problem

If you’ve installed ExpressionEngine but find you get a ‘No input file specified’ error message on anything but the home page of the site, chances are it’s because your server doesn’t support the path_info server variable.

This happened to me recently when my web host migrated my accounts to a new server and in the process made some configuration changes, one of which involved disabling path_info.

According to the ExpressionEngine Knowledge Base, there are a couple of options available to you if this is the case with your server:

  • You can turn on the ‘Force Query String’ setting in the ExpressionEngine control panel, found at Admin | System Preferences | Output and Debugging Preferences. This of course means that all your URLs will have a query string in them and look something like www.example.com/?/filename/.

  • Or you can edit your index.php and replace:

    $path_info = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');

    with

    $path_info = (isset($_SERVER['ORIG_PATH_INFO'])) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');

So essentially, just replacing PATH_INFO with ORIG_PATH_INFO.

In my case, however, this wasn’t quite enough and as I didn’t find any mention of this important little fact anywhere, I thought it was worth mentioning here. The reason the workarounds weren’t working was because I was also using a .htaccess file to remove index.php from the URL:

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

What was missing was the ? from the rewrite rule, so the last line should look like:

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

As one of the technical support guys at my host said, “It’s always the little things that cause the most trouble.” ;)

Share this post
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Reddit

Browse by tags:

Tags: , ,

Subscribe to this site for regular updates

20 responses to ‘No input file specified’ problem. Add your own.

Comments

  1. 1

    Great tip! Fixed my issue! Thanks you very much. Oh mod_rewrite how I hate thee…. :)

  2. 2

    Adding that little question mark fixed my file as well! However, I know thecity.org has removed index.php, but they don’t have a ? in their .htaccess file. So, whatever, hopefully there will be no negative effects.

  3. 3

    Whether you need the ? will depend on your web host. For sites I’d done I didn’t originally need it either, but then my host made some configuration changes after which I did need to do it.

  4. 4

    Worked! ;) thanx a lot mate

  5. 5

    Thank you!!! Saved me a ton of time!

  6. 6

    Thank you so much for this post. Solved my problem easily. I couldn’t figure out what was going on as I had all my settings correct according to the host.

    PS – small typo:

    So essentially, just replacing ORIG_PATH_INFO with ORIG_PATH_INFO.

    should read

    So essentially, just replacing PATH_INFO with ORIG_PATH_INFO.

  7. 7

    Hi Philip, thanks for pointing that out. :)

  8. 8

    For anyone who might be using CodeIgniter with mod_rewrite on Fasthosts web hosting in the UK, the question mark tip fixes the problem!

    You’ve saved me hours John, thank you!

  9. 9

    No problem. :)

  10. 10

    Thanks for this, much appreciated!

  11. 11

    Thanks a lot
    solved my problem

  12. 12

    +1 thankyou! :D

  13. 13

    I also ran into this issue, while using EE’s “include method” to remove the index.php. So adding the ? into the RewriteRule rule worked. But now I’m unable to correctly implement redirects. e.g.
    RedirectMatch 301 /bar/ http://www.domain.com/foo/

    results in a redirect to
    http://www.domain.com/foo/?/bar/

    so far no luck figuring out why and how to fix it.

  14. 14

    Steve, writing .htaccess isn’t my strong suit either but could you do RedirectMatch 301 /bar/ http://www.domain.com/index.php/foo/ and then move that above the rules that remove the index.php so that the redirect then gets included in the rewrite that follows?

  15. 15

    Nice one mate, this is why sharing your troubles is always good for everyone.

    Fingers crossed it will be simple from here on… (yeh right)

  16. 16

    @steve @john

    I had the same issues and came up with a pretty good fix that allows me to use both the include method for removing htaccess, the ? fix after index.php, and normal 301 redirects.

    First it’s worth noting that changing to CGI instead of FastCGI works perfectly. It seems that only FastCGI requires the ? to trigger queries. But I don’t want to lose the performance boost of FastCGI.

    Basically, it seems that the 301s only run after all the rewriterules (regardless of placement within htaccess. So you can’t 301 before the rewriterule runs. And if the rewriterule runs prior to the 301, the index.php? gets carried along and leaves that ? as a fragment in the url.

    So in order to 301 without having the index.php? added, you can simply exclude those urls you want to 301 from the main rewriterule, with a custom rewritecond.

    My include method section looked like this:


    # Exclude paths with an extension
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
    # Exclude bad file paths
    RewriteCond %{REQUEST_FILENAME} !-f
    # Include anything starting in these segments
    RewriteCond %{REQUEST_URI} ^/(Every possible segment_1 goes here, pipe-delimited|P[0-9]{2,8}) [NC]
    # Rewrite the url with the index.php?
    RewriteRule ^(.*)$ /index.php?/$1/ [L]

    I added a line at the beginning like this:

    RewriteCond %{REQUEST_URI} !^/(old_url|older_url/old_page)$

    Then elsewhere in htaccess:

    redirect 301 /old_url/ http://domain.com/new_url/
    redirect 301 /older_url/old_page/ http://domain.com/another_url/

    So basically you allow the old paths to pass through htaccess unscathed (aside from adding or removing www, adding or removing a trailing slash, whatever). Then the client hits the 301 and goes to the new url, which also hits htacess but this time gets the index.php?

    Hope this helps!

  17. 17

    I forgot a trailing slash after:


    RewriteCond %{REQUEST_URI} !^/(old_url|older_url/old_page)/$

    Note that this trailing slash is only required if you’re rewriting your urls in htaccess to include them. If you are removing them in htaccess, remove the end slash. If you’re not touching them in htaccess, don’t use the $ at the end (but only if you don’t mind losing all directories under the directories you’re skipping in this rewritecond)

  18. 18

    Thanks Ty. If the situation ever comes up again, I’ll be sure to try your suggestion out. :)

  19. 19

    Worked perfectly for me too. Thanks a lot for the post.

Pingbacks

  1. 1

    [...] ‘No input file specified’ problem — Tyssen Design (tags: php apache htaccess) [...]

Feed for this post's comments


Required indicates required field.
Email will not be published

You can use these tags in your reply:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Leave a Reply

Contact details

Spam Protection by WP-SpamFree