Viewed   188 times

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/

 Answers

4

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]
Thursday, October 20, 2022
3

I find with xampp and wamp this htaccess use full.

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Make you place the htaccess file out side of the main application folder.

Set your base url some thing like

$config['base_url'] = 'http://localhost/project/';
$config['index_page'] = '';

Note: You can leave base url blank but some times when you submit a form you will find may not submit correctly. because it shows ip_adress in url instead of localhost

Directory

application

system

.htaccess

index.php

With codeIgniter 3 versions make sure also you have class and file names first letter upper case.

File name example: Welcome.php

<?php

class Welcome extends CI_Controller {

     public function index() {

     }
}
Tuesday, November 8, 2022
3

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.

Wednesday, December 7, 2022
 
wedge
 
3

The No input file specified is a message you are presented with because of the implementation of PHP on your server, which in this case indicates a CGI implementation (can be verified with phpinfo()).

Now, to properly explain this, you need to have some basic understanding on how your system works with URL's. Based on your .htaccess file, it seems that your CMS expects the URL to passed along as a PATH_INFO variable. CGI and FastCGI implementations do not have PATH_INFO available, so when trying to pass the URI along, PHP fails with that message.

We need to find an alternative.

One option is to try and fix this. Looking into the documentation for core php.ini directives you can see that you can change the workings for your implementation. Although, GoDaddy probably won't allow you to change PHP settings on a shared enviroment.

We need to find an alternative to modifying PHP settings
Looking into system/uri.php on line 40, you will see that the CMS attempts two types of URI detection - the first being PATH_INFO, which we just learned won't work - the other being the REQUEST_URI.

This should basically, be enough - but the parsing of the URI passed, will cause you more trouble, as the URI, which you could pass to REQUEST_URI variable, forces parse_url() to only return the URL path - which basically puts you back to zero.

Now, there's actually only one possibilty left - and that's changing the core of the CMS. The URI detection part is insufficient.

Add QUERY_STRING to the array on line 40 as the first element in system/uri.php and change your .htaccess to look like this:

RewriteEngine On 

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

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

This will pass the URI you request to index.php as QUERY_STRING and have the URI detection to find it.

This, on the other hand, makes it impossible to update the CMS without changing core files till this have been fixed. That sucks...

Need a better option?
Find a better CMS.

Tuesday, October 4, 2022
 
2
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

RewriteEngine On "starts" rewriting. RewriteCond and RewriteRule work as pairs. Here, we send user to non-www version first, and cleans URLs.

Thursday, August 11, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :