{"id":607,"date":"2011-12-11T13:34:29","date_gmt":"2011-12-11T21:34:29","guid":{"rendered":"http:\/\/blog.portnumber53.com\/?p=607"},"modified":"2011-12-11T13:34:29","modified_gmt":"2011-12-11T21:34:29","slug":"kohana-3-2-tutorial-2-setting-up","status":"publish","type":"post","link":"https:\/\/blog.portnumber53.com\/index.php\/2011\/12\/11\/kohana-3-2-tutorial-2-setting-up\/","title":{"rendered":"Kohana 3.2 tutorial : 2 \u2013 Setting up and basic Redirect controller"},"content":{"rendered":"<p>1. Edit bootstrap.php under &#8220;application&#8221;:<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<pre>date_default_timezone_set('America\/Los_Angeles');<\/pre>\n<pre>Kohana::init(array(\n        'base_url'   =&gt; '\/',\n        'index_file' =&gt; '',\n));<\/pre>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>2. Change the default route to a redirect controller (so we can deal with redirections for misplaced content\/old content):<\/p>\n<pre>Route::set('default', '(&lt;request&gt;)',\n\tarray(\n\t\t'request' =&gt; '(.*)',\n\t))\n\t-&gt;defaults(array(\n\t\t'controller' =&gt; 'redirect',\n\t\t'action'     =&gt; 'index',\n\t));<\/pre>\n<p>3.Create the redirect controller<\/p>\n<p>\/modules\/redirect\/classes\/controller\/redirect.php<\/p>\n<pre>&lt;?php<\/pre>\n<pre> defined('SYSPATH') or die('No direct script access.');\n\/**\n * Handles all the redirecions that may happen\n *\n * @package      Redirect\n * @category     SEO\n * @author       Mauricio Otta\n * @license      Confidential. Internal use only.\n *\/<\/pre>\n<pre>class Controller_Redirect extends Controller {\n\n\tstatic public function action_index() {\n\t\techo \"Controller_Redirect::action_index();&lt;br \/&gt;\";\n\t\techo Request::current()-&gt;param('request');\n\t}\n\n}<\/pre>\n<p>4. Test it.<\/p>\n<p>You should see something like this:<\/p>\n<p>&#8220;Controller_Redirect::action_index();&#8221;<\/p>\n<p>test with different URLs.<\/p>\n<p>Notice the controller does not handle the Query String part ( http:\/\/php.net\/parse_url )<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>TO-DO: Add query string handling<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Edit bootstrap.php under &#8220;application&#8221;: &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; date_default_timezone_set(&#8216;America\/Los_Angeles&#8217;); Kohana::init(array( &#8216;base_url&#8217; =&gt; &#8216;\/&#8217;, &#8216;index_file&#8217; =&gt; &#8221;, )); &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2. Change the default route to a redirect controller (so we can deal with redirections for misplaced content\/old content): Route::set(&#8216;default&#8217;, &#8216;(&lt;request&gt;)&#8217;, array( &#8216;request&#8217; =&gt; &#8216;(.*)&#8217;, )) -&gt;defaults(array( &#8216;controller&#8217; =&gt; &#8216;redirect&#8217;, &#8216;action&#8217; =&gt; &#8216;index&#8217;, ));&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/blog.portnumber53.com\/index.php\/2011\/12\/11\/kohana-3-2-tutorial-2-setting-up\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,24],"tags":[],"class_list":["post-607","post","type-post","status-publish","format-standard","hentry","category-kohana","category-tutorial-2"],"_links":{"self":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/comments?post=607"}],"version-history":[{"count":0,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/607\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/media?parent=607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/categories?post=607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/tags?post=607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}