views:

66

answers:

2

Codeigniter php framework URLs look like the above.

I'm surprised that apache maps this request to index.php at the server root. I expected it to interpret /index.php/abc/def as a file 'abc' in a directory /index.php/abc, and as a result a 404 Not Found (given that no such file exists).

Can anyone explain why index.php gets executed instead? Is there a document that explains apaches 'map request to resource' strategy, that would explain the above observation?

+3  A: 

Because when it looks in the root folder it sees index.php is a file not a folder, so it executes that file rather than looking inside it (if it was a directory) for the next element of the path.

The rest of the "path" then becomes an unconventional querystring of sorts

Greg B
+2  A: 

index.php is an actual file in the document root of your project. The framework is setup to route all requests to this file. It is also typically called a "bootstrap" file. The bootstrap file is responsible for starting up your application and ultimately getting your request where it needs to go.

There is a router in the framework that takes in the uri, everything after index.php and then maps that to a controller/action combination.

Chris Gutierrez