Patrick
Patrick

Reputation: 1275

links in codeigniter

I'm experimenting with codeigniter but don't really understand how links work.

for example, I have a link like this:

localhost/ci/welcome/cat/7

My base url is localhost/ci, so by clicking on this link I would expect the method "cat" of controller "welcome" to be called.

This method is very simple:

   function cat()
    { 
        echo "just a test.";
    }

Pretty basic - I would expect to see the text on screen, but I just see a 404 -page not found error.

What could be the problem?

Upvotes: 1

Views: 2160

Answers (3)

Stephen Curran
Stephen Curran

Reputation: 7433

I had problems with the rewrite rule suggested in the user guide. I was also getting 404s. I had to remove the slash before index.php in the rule.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

As Veeti says, also remember to enable mod_rewrite for Apache.

Upvotes: 0

Veeti
Veeti

Reputation: 5300

Have you configured mod_rewrite (or URL rewriting in general) properly for CodeIgniter? It's not supported out of the box.

They have some instructions in their wiki.

Upvotes: 2

Related Questions