Question

I keep getting the following error when i navigate to: http://localhost:81/framework/:

Kohana_HTTP_Exception [ 404 ]: The requested URL framework was not found on this server.

enter image description here

My Controller:

<?php defined('SYSPATH') OR die('No Direct Script Access');

Class Controller_Welcome extends Controller_Template
{
    public $template = 'site';

    public function action_index()
    {
        $this->template->message = 'hello, world!';
    }
}

My bootstrap.php file looks like this:

<?php defined('SYSPATH') or die('No direct script access.');

// -- Environment setup --------------------------------------------------------

/**
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
 * - string   index_file  name of your index file, usually "index.php"       index.php
 * - string   charset     internal character set used for input and output   utf-8
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - integer  cache_life  lifetime, in seconds, of items cached              60
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 * - boolean  expose      set the X-Powered-By header                        FALSE
 */
Kohana::init(array(
    'base_url'   => '/kohana/',
));

/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Log_File(APPPATH.'logs'));

/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Config_File);

/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array(
    // 'auth'       => MODPATH.'auth',       // Basic authentication
    // 'cache'      => MODPATH.'cache',      // Caching with multiple backends
    // 'codebench'  => MODPATH.'codebench',  // Benchmarking tool
    // 'database'   => MODPATH.'database',   // Database access
    // 'image'      => MODPATH.'image',      // Image manipulation
    // 'minion'     => MODPATH.'minion',     // CLI Tasks
    // 'orm'        => MODPATH.'orm',        // Object Relationship Mapping
    // 'unittest'   => MODPATH.'unittest',   // Unit testing
    // 'userguide'  => MODPATH.'userguide',  // User guide and API documentation
    ));

/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('default', '(<controller>(/<action>(/<id>)))')
    ->defaults(array(
        'controller' => 'welcome',
        'action'     => 'index',
    ));

I have also tried creating a view called site.php located in the following directory: http://localhost/framework/application/views/site.php

site.php

<html>
    <head>
        <title>We've got a message for you!</title>
        <style type="text/css">
            body {font-family: Georgia;}
            h1 {font-style: italic;}

        </style>
    </head>
    <body>
        <h1><?php echo $message; ?></h1>
        <p>We just wanted to say it! :)</p>
    </body>
</html>

I get the following error when i navigate to site.php:

enter image description here

Was it helpful?

Solution

You need to set proper path (which is /framework/) in your bootstrap.php ('base_url' => /framework/ in Kohana::init part) and .htaccess RewriteBase (RewriteBase /framework/)

OTHER TIPS

The problem was in the basestrap.php i didnt set the base URL:

Before:

Kohana::init(array(
    'base_url'   => '/kohana/',
));

After:

Kohana::init(array(
    'base_url'   => '/framework/',
));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top