{"id":11659,"date":"2019-10-30T10:26:13","date_gmt":"2019-10-30T10:26:13","guid":{"rendered":"https:\/\/blog.startbitsolutions.com\/?p=11659"},"modified":"2019-10-31T12:24:57","modified_gmt":"2019-10-31T12:24:57","slug":"default-routing-in-codeigniter","status":"publish","type":"post","link":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/","title":{"rendered":"Default Routing In Codeigniter"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">One of the most common problem that a beginner faces with codeigniter is the presence of index.php in the URL just before the name of the controller. This makes the URL look odd. Also, whenever developers are trying to form a link during the development of a project, it becomes mandatory for the developer to add index.php in the URL otherwise the application does not work and keeps on providing a 404 Error (Not FOund).<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">So, in order to make the URL of the codeigniter user friendly , we can use .htaccess file. This .htaccess file helps us in changing the default routing behavior of Codeigniter. This .htaccess file contains some line of code which can help us achieve our target and it is placed in the root directory of codeigniter framework i.e. along with the application folder (NOT inside the application folder).<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Here is a sample block of code that we can place in the .htaccess file :<\/pre>\n\n\n\n<p>RewriteEngine On<br>\nRewriteBase \/builder<br>\nRewriteRule ^index.php$ &#8211; [L]<br>\nRewriteCond %{REQUEST_FILENAME} !-f<br>\nRewriteCond %{REQUEST_FILENAME} !-d<br>\nRewriteCond $1 !^(index.php|images|robots.txt|css|docs|js|system)<br>\nRewriteRule ^(.*)$ \/builder\/index.php?\/$1 [L]<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Please note the last line in the block of code. There is index.php written over there. We are also adding something just before the index.php in the last line of code. This additional thing is nothing but the name of the folder which holds the codeigniter application. We are also placing name of the folder in the second line.<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Doing only and only this we can not fully change the routing behaviour and resolve our problem related to the presence of index.php in the URL. After placing the code in the .htaccess file and then placing the .htaccess file in the root directory of codeigniter. We now need to make some changes to the config.php file. The config.php file is located in the application\/config folder. When you open config.php file you will find $config array in the file. This $config array holds various configuration parameters required to run codeigniter application. One of these parameters is index_page. It will look something like this $config['index_page'] and it will be the next parameter after base_url. By default , it will contain the value index.php. We need to make it blank i.e.  $config['index_page'] = '';.<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Now, our work is complete and we can now run the codeigniter application without the presence of index.php in the URL.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>One of the most common problem that a beginner faces with codeigniter is the presence of index.php in the URL just before the name of the controller. This makes the URL look odd. Also, whenever developers are trying to form a link during the development of a project, it becomes mandatory for the developer to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":11669,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,441,453,450,452],"tags":[1142,1143],"class_list":["post-11659","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-php","category-php-scripts","category-techniques","category-web-design-programming","tag-codeigniter","tag-codeigniter-default-routing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Default Routing In Codeigniter - Blog -Startbit IT Solutions Pvt. Ltd.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Default Routing In Codeigniter - Blog -Startbit IT Solutions Pvt. Ltd.\" \/>\n<meta property=\"og:description\" content=\"One of the most common problem that a beginner faces with codeigniter is the presence of index.php in the URL just before the name of the controller. This makes the URL look odd. Also, whenever developers are trying to form a link during the development of a project, it becomes mandatory for the developer to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog -Startbit IT Solutions Pvt. Ltd.\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-30T10:26:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-31T12:24:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png\" \/>\n\t<meta property=\"og:image:width\" content=\"620\" \/>\n\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Startbit Solutions Pvt. Ltd.\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Startbit Solutions Pvt. Ltd.\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/\"},\"author\":{\"name\":\"Startbit Solutions Pvt. Ltd.\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/#\/schema\/person\/e987833901c2ac8311d63cfbc168caae\"},\"headline\":\"Default Routing In Codeigniter\",\"datePublished\":\"2019-10-30T10:26:13+00:00\",\"dateModified\":\"2019-10-31T12:24:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/\"},\"wordCount\":36,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png\",\"keywords\":[\"codeigniter\",\"codeigniter default routing\"],\"articleSection\":[\"Blog\",\"PHP\",\"PHP Scripts\",\"Techniques\",\"Web Design &amp; Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/\",\"url\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/\",\"name\":\"Default Routing In Codeigniter - Blog -Startbit IT Solutions Pvt. Ltd.\",\"isPartOf\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png\",\"datePublished\":\"2019-10-30T10:26:13+00:00\",\"dateModified\":\"2019-10-31T12:24:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#primaryimage\",\"url\":\"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png\",\"contentUrl\":\"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png\",\"width\":620,\"height\":350,\"caption\":\"CodeIgniter-Startbit-Solutions.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.startbitsolutions.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Default Routing In Codeigniter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/#website\",\"url\":\"https:\/\/blog.startbitsolutions.com\/\",\"name\":\"Blog -Startbit IT Solutions Pvt. Ltd.\",\"description\":\"Designing the future\",\"publisher\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.startbitsolutions.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/#organization\",\"name\":\"Blog -Startbit IT Solutions Pvt. Ltd.\",\"url\":\"https:\/\/blog.startbitsolutions.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/02\/cropped-startbit-1.png\",\"contentUrl\":\"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/02\/cropped-startbit-1.png\",\"width\":1000,\"height\":250,\"caption\":\"Blog -Startbit IT Solutions Pvt. Ltd.\"},\"image\":{\"@id\":\"https:\/\/blog.startbitsolutions.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/#\/schema\/person\/e987833901c2ac8311d63cfbc168caae\",\"name\":\"Startbit Solutions Pvt. Ltd.\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.startbitsolutions.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/200496fa36c9648776985343159a0838d416b4321b2108021499600db502fcce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/200496fa36c9648776985343159a0838d416b4321b2108021499600db502fcce?s=96&d=mm&r=g\",\"caption\":\"Startbit Solutions Pvt. Ltd.\"},\"url\":\"https:\/\/blog.startbitsolutions.com\/author\/startbit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Default Routing In Codeigniter - Blog -Startbit IT Solutions Pvt. Ltd.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/","og_locale":"en_US","og_type":"article","og_title":"Default Routing In Codeigniter - Blog -Startbit IT Solutions Pvt. Ltd.","og_description":"One of the most common problem that a beginner faces with codeigniter is the presence of index.php in the URL just before the name of the controller. This makes the URL look odd. Also, whenever developers are trying to form a link during the development of a project, it becomes mandatory for the developer to [&hellip;]","og_url":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/","og_site_name":"Blog -Startbit IT Solutions Pvt. Ltd.","article_published_time":"2019-10-30T10:26:13+00:00","article_modified_time":"2019-10-31T12:24:57+00:00","og_image":[{"width":620,"height":350,"url":"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png","type":"image\/png"}],"author":"Startbit Solutions Pvt. Ltd.","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Startbit Solutions Pvt. Ltd.","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#article","isPartOf":{"@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/"},"author":{"name":"Startbit Solutions Pvt. Ltd.","@id":"https:\/\/blog.startbitsolutions.com\/#\/schema\/person\/e987833901c2ac8311d63cfbc168caae"},"headline":"Default Routing In Codeigniter","datePublished":"2019-10-30T10:26:13+00:00","dateModified":"2019-10-31T12:24:57+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/"},"wordCount":36,"commentCount":0,"publisher":{"@id":"https:\/\/blog.startbitsolutions.com\/#organization"},"image":{"@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png","keywords":["codeigniter","codeigniter default routing"],"articleSection":["Blog","PHP","PHP Scripts","Techniques","Web Design &amp; Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/","url":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/","name":"Default Routing In Codeigniter - Blog -Startbit IT Solutions Pvt. Ltd.","isPartOf":{"@id":"https:\/\/blog.startbitsolutions.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#primaryimage"},"image":{"@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png","datePublished":"2019-10-30T10:26:13+00:00","dateModified":"2019-10-31T12:24:57+00:00","breadcrumb":{"@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#primaryimage","url":"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png","contentUrl":"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/10\/CodeIgniter-Startbit-Solutions.png","width":620,"height":350,"caption":"CodeIgniter-Startbit-Solutions.png"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.startbitsolutions.com\/default-routing-in-codeigniter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.startbitsolutions.com\/"},{"@type":"ListItem","position":2,"name":"Default Routing In Codeigniter"}]},{"@type":"WebSite","@id":"https:\/\/blog.startbitsolutions.com\/#website","url":"https:\/\/blog.startbitsolutions.com\/","name":"Blog -Startbit IT Solutions Pvt. Ltd.","description":"Designing the future","publisher":{"@id":"https:\/\/blog.startbitsolutions.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.startbitsolutions.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/blog.startbitsolutions.com\/#organization","name":"Blog -Startbit IT Solutions Pvt. Ltd.","url":"https:\/\/blog.startbitsolutions.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.startbitsolutions.com\/#\/schema\/logo\/image\/","url":"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/02\/cropped-startbit-1.png","contentUrl":"https:\/\/blog.startbitsolutions.com\/wp-content\/uploads\/2019\/02\/cropped-startbit-1.png","width":1000,"height":250,"caption":"Blog -Startbit IT Solutions Pvt. Ltd."},"image":{"@id":"https:\/\/blog.startbitsolutions.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/blog.startbitsolutions.com\/#\/schema\/person\/e987833901c2ac8311d63cfbc168caae","name":"Startbit Solutions Pvt. Ltd.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.startbitsolutions.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/200496fa36c9648776985343159a0838d416b4321b2108021499600db502fcce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/200496fa36c9648776985343159a0838d416b4321b2108021499600db502fcce?s=96&d=mm&r=g","caption":"Startbit Solutions Pvt. Ltd."},"url":"https:\/\/blog.startbitsolutions.com\/author\/startbit\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/posts\/11659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/comments?post=11659"}],"version-history":[{"count":2,"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/posts\/11659\/revisions"}],"predecessor-version":[{"id":11661,"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/posts\/11659\/revisions\/11661"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/media\/11669"}],"wp:attachment":[{"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/media?parent=11659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/categories?post=11659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.startbitsolutions.com\/wp-json\/wp\/v2\/tags?post=11659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}