Thursday, 8 October 2009

Remove index.php from the URL in Kohana

If you read the Kohana documentation they will tell you to edit your .htaccess file in order to remove index.php from your URLs, so that

http://localhost/kohana/index.php/controller/view

becomes

http://localhost/kohana/controller/view

But it is my experience that when creating URLs using the framework's helpers, like so:

<?php echo html::anchor('controller/view', 'Title'); ?>

Even with the htaccess modification, it will show the url as

http://localhost/kohana/index.php/controller/view

What you need to do is to edit the file:

/kohana/application/config/config.php

and modify this line to:

$config['index_page'] = '';

Now your URLs will not have index.php in them and the htaccess file can do its job.

No comments:

Post a Comment