.htaccess :: mod_rewrite issue – No input file specified – Solution

In one recent project, I have faced strange problem with mod_rewrite. In many projects, I have seen that many hosting server has not .htaccess enabled by default. But in this case mod_rewrite is enabled but not working with common and general syntax for URL rewriting.

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

This syntax produce error with text is “No input file specified”, it is happened in Heart Internet hosting server. This is really painful for development. After play with syntax I have found strange fix with regular expression. This is really strange fix and definitely ridiculous. Let see the solution for “No input file specified.” issue, it might save your hours of painful effort.

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

Do you find any difference between 2 syntax snippet? Closer look will revealed the difference. Let’s compare the difference here –

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

“^” is start of the string and “$” is the end of the string. And “.” denotes many occurrence will come in the string, “*” denotes continue the matches. And parenthesis “()” is storing the desired content in to variable. So, “^(.*)$” will get complete query string from the url and will put as query string after “index.php”.

But in this case, Heart Internet hosting doesn’t interpret the expression rightly and error raised – “No input file specified”. You can see the strange fix here is –

RewriteRule .$ index.php/$1 [L]

No start but has end, many occurrence but not continuation. But it works! Any idea!!!

Similarly Godaddy hosting has same error with general syntax for mod_rewrite. Just adding this line in the .htaccess will fix the issue.

Options -MultiViews

You can share your experience and knowledge to save several hours for others. Thanks.


All comments of post - ".htaccess :: mod_rewrite issue – No input file specified – Solution":

:Haha! I'am the first! Yeh~

Comments are currently closed.

Add a Comment / Trackback url

  1. #1  Connie

    That saves me. Tahkns for being so sensible!

    11/05/13 19:34

Show all Show 5 so far Close all

Comment begin from here or jump up!