Codeigniter remove index.php from url Apache and IIS

If you want to remove the index.php from your Codeigniter URL there are two easy steps:

1)Setup you Config.php file under your application/config

$config[‘index_page’] = ””; /blank

2) Create a file named .htaccess and write this code

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /tarjetamp
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<IfModule !mod_rewrite.c>
ErrorDocument 404 /codeigniter/index.php

And that is all :)

PD: if you are running under IIS you must write in your web.config

<rule name=”RuleRemoveIndex” stopProcessing=”true”>
<match url=”^(.*)$” ignoreCase=”false” />
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” ignoreCase=”false” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” ignoreCase=”false” negate=”true” />
<add input=”{URL}” pattern=”^/favicon.ico$” ignoreCase=”false” negate=”true” />
<action type=”Rewrite” url=”/index.php/{R:1}” appendQueryString=”true”/>

Share Button

Leave a Reply

Your email address will not be published. Required fields are marked *