Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed assistance with Kohana 3 and catch all route turning into a 404 error
    primarykey
    data
    text
    <p>Based on <a href="http://kerkness.ca/wiki/doku.php?id=routing:creating_a_custom_404_page" rel="nofollow noreferrer">this documentation</a>, I've implemented a <em>catch all</em> route which routes to an error page.</p> <p>Here is the last route in my <code>bootstrap.php</code></p> <pre><code>Route::set('default', '&lt;path&gt;', array('path' =&gt; '.+')) -&gt;defaults(array( 'controller' =&gt; 'errors', 'action' =&gt; '404', )); </code></pre> <p>However I keep getting this exception thrown when I try and go to a non existent page</p> <blockquote> <p>Kohana_Exception [ 0 ]: Required route parameter not passed: path</p> </blockquote> <p>If I make the <code>&lt;path&gt;</code> segment optional (i.e. wrap it in parenthesis) then it just seems to load the <code>home</code> route, which is...</p> <pre><code>Route::set('home', '') -&gt;defaults(array( 'controller' =&gt; 'home', 'action' =&gt; 'index', )); </code></pre> <p>The home route is defined first.</p> <p>I execute my main request like so</p> <pre><code>$request = Request::instance(); try { // Attempt to execute the response $request-&gt;execute(); } catch (Exception $e) { if (Kohana::$environment === Kohana::DEVELOPMENT) throw $e; // Log the error Kohana::$log-&gt;add(Kohana::ERROR, Kohana::exception_text($e)); // Create a 404 response $request-&gt;status = 404; $request-&gt;response = Request::factory(Route::get('default')-&gt;uri())-&gt;execute(); } $request-&gt;send_headers(); echo $request-&gt;response; </code></pre> <p>This means that the 404 header is sent to the browser, but I assumed by sending the request to the capture all route then it should show the 404 error set up in my errors controller.</p> <pre><code>&lt;?php defined('SYSPATH') or die('No direct script access.'); class Controller_Errors extends Controller_Base { public function before() { parent::before(); } public function action_404() { $this-&gt;bodyClass[] = '404'; $this-&gt;internalView = View::factory('internal/not_found'); $longTitle = 'Page Not Found'; $this-&gt;titlePrefix = $longTitle; } } </code></pre> <p>Why won't it show my 404 error page?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload