views:

339

answers:

5

I was going through the official Code Igniter tutorial when I hit a snag...

The tutorial had me save and run this code:

<?php
class Blog extends Controller {

     function index()
     {
         echo 'Hello World!';
     }

     function comments()
     {
         echo 'Look at this!';
     }
}
?>

IF I enter the following URL:

index.php/blog

it works and displays "Hello World!".

When I modify the URL to display the comments as follows:

index.php/blog/comments/

I get a 404.

Thanks

+1  A: 

By default, your example should work. Examine your configurations and remove .htaccess as your example aren't using mod_rewrite.

Start from scratch also helps you learn ;)

rockacola
A: 

I's a file update issue.

Jarrod
+1  A: 

if you add a ? after index.php does it work?

http://example.com/index.php?/blog/comments
gaker
A: 

I had the same problem. Ended up being that I never closed one my first function - I left off the last }. So the function I didn't close worked fine but everything after that kept giving me a 404.

Brandon
A: 

It's always worth trying out some of the $config['uri_protocol'] options in application/config/config.php.

/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.  The default setting of "AUTO" works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO'      Default - auto detects
| 'PATH_INFO'    Uses the PATH_INFO
| 'QUERY_STRING'    Uses the QUERY_STRING
| 'REQUEST_URI'  Uses the REQUEST_URI
| 'ORIG_PATH_INFO'  Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';

Some servers have issues with different options, so try each manually. This may not work in your case but has saved the day for me in the past.

Phil Sturgeon