{"id":835,"date":"2013-08-12T02:08:24","date_gmt":"2013-08-12T00:08:24","guid":{"rendered":"https:\/\/www.npcglib.org\/~stathis\/blog\/?p=835"},"modified":"2013-09-18T04:52:40","modified_gmt":"2013-09-18T02:52:40","slug":"apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter","status":"publish","type":"post","link":"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/","title":{"rendered":"apache tip: Rewriting CodeIgniter URLs on Apache 2.4 + PHP FPM + mod_fastcgi_handler"},"content":{"rendered":"<p>Getting CodeIgniter URLs properly rewritten is a bit tricky when using FastCGI, including the <a href=\"https:\/\/github.com\/hollow\/mod_fastcgi_handler\" target=\"_blank\">mod_fastcgi_handler<\/a>. Typically, we want to remove the <code>index.php<\/code> from all urls. To do this, create an <code>.htaccess<\/code> file in the same directory with <code>index.php<\/code> and paste into it:<\/p>\n<pre>\r\nOptions -Indexes +FollowSymLinks\r\n\r\nRewriteEngine On\r\nRewriteBase \/\r\n\r\n# exclude any paths that are not codeigniter-app related\r\nRewriteCond %{REQUEST_URI} !^\/server-status\r\nRewriteCond %{REQUEST_URI} !^\/server-info\r\nRewriteCond %{REQUEST_URI} !^\/docs\r\n\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\n\r\n&lt;IfModule mod_php5.c&gt; \r\n    RewriteRule ^(.*)$ index.php\/$1 [L]    \r\n&lt;\/IfModule&gt;    \r\n\r\n# the following is for rewritting under FastCGI\r\n&lt;IfModule !mod_php5.c&gt;    \r\n    RewriteRule ^(.*)$ index.php?\/$1 [L]\r\n&lt;\/IfModule&gt;\r\n<\/pre>\n<h3>Acknowledgements<\/h3>\n<p><b>Full credit for the right mod_rewrite rule goes to <a href=\"http:\/\/philsturgeon.co.uk\/\" target=\"_blank\">Phil Sturgeon<\/a> who has posted it <a href=\"http:\/\/ellislab.com\/forums\/viewthread\/159406\/#767527\" target=\"_blank\">here<\/a>.<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting CodeIgniter URLs properly rewritten is a bit tricky when using FastCGI, including the mod_fastcgi_handler. Typically, we want to remove the index.php from all urls. To do this, create an .htaccess file in the same directory with index.php and paste into it: Options -Indexes +FollowSymLinks RewriteEngine On RewriteBase \/ # exclude any paths that are [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[48],"tags":[49,58,61,60,59],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"description\" content=\"In this post it is explained how to rewrite URLs in Apache using mod_rewrite for CodeIgniter framework applications with PHP FPM and mod_fastcgi_handler.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"stathis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#website\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/\",\"name\":\"sigmoid\",\"description\":\"..oo..oo..oo..oo..oo..oo..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/#webpage\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/\",\"name\":\"Rewriting CodeIgniter URLs on Apache 2.4 + PHP FPM + mod_fastcgi_handler\",\"isPartOf\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#website\"},\"datePublished\":\"2013-08-12T00:08:24+00:00\",\"dateModified\":\"2013-09-18T02:52:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41\"},\"description\":\"In this post it is explained how to rewrite URLs in Apache using mod_rewrite for CodeIgniter framework applications with PHP FPM and mod_fastcgi_handler.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"apache tip: Rewriting CodeIgniter URLs on Apache 2.4 + PHP FPM + mod_fastcgi_handler\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41\",\"name\":\"stathis\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g\",\"caption\":\"stathis\"},\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/author\/stathis\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"description":"In this post it is explained how to rewrite URLs in Apache using mod_rewrite for CodeIgniter framework applications with PHP FPM and mod_fastcgi_handler.","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:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/","twitter_misc":{"Written by":"stathis","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#website","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/","name":"sigmoid","description":"..oo..oo..oo..oo..oo..oo..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.npcglib.org\/~stathis\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/#webpage","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/","name":"Rewriting CodeIgniter URLs on Apache 2.4 + PHP FPM + mod_fastcgi_handler","isPartOf":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#website"},"datePublished":"2013-08-12T00:08:24+00:00","dateModified":"2013-09-18T02:52:40+00:00","author":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41"},"description":"In this post it is explained how to rewrite URLs in Apache using mod_rewrite for CodeIgniter framework applications with PHP FPM and mod_fastcgi_handler.","breadcrumb":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2013\/08\/12\/apache-tip-rewriting-urls-with-apache-2-4-php-fpm-mod_fastcgi_handler-codeigniter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.npcglib.org\/~stathis\/blog\/"},{"@type":"ListItem","position":2,"name":"apache tip: Rewriting CodeIgniter URLs on Apache 2.4 + PHP FPM + mod_fastcgi_handler"}]},{"@type":"Person","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41","name":"stathis","image":{"@type":"ImageObject","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#personlogo","inLanguage":"en-US","url":"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g","caption":"stathis"},"url":"https:\/\/www.npcglib.org\/~stathis\/blog\/author\/stathis\/"}]}},"_links":{"self":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/835"}],"collection":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/comments?post=835"}],"version-history":[{"count":10,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/835\/revisions"}],"predecessor-version":[{"id":903,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/835\/revisions\/903"}],"wp:attachment":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/media?parent=835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/categories?post=835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/tags?post=835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}