Saturday, January 11, 2014

When it comes to removing index.php from url Kohana documentation is not very helpful (or at least does not tell anything useful.)

There are 2 steps:

1 .You have to add this code to your bootstrap.php

Kohana::init(array(
    'base_url'   => '/myapp/',
    'index_file' => FALSE,
));

2. Change your .htaccess file into this:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /kohana/

# Allow these directories and files to be displayed directly:
# - index.php (DO NOT FORGET THIS!)
# - robots.txt
# - favicon.ico
# - Any file inside of the media/ directory
RewriteRule ^(index\.php|robots\.txt|favicon\.ico|media|uploads) - [PT,L]

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php?/$0 [PT,L,QSA]

See this thread for details.

Actually you have to put your media files (like js, img or css) in main directory, the same where your application and system lives.

Do not forget to check if mod_rewrite is enabled.

No comments:

Post a Comment