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>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /codeigniter/index.php
</IfModule>

And that is all :)

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

<rewrite>
<rules>
<rule name=”RuleRemoveIndex” stopProcessing=”true”>
<match url=”^(.*)$” ignoreCase=”false” />
<conditions>
<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” />
</conditions>
<action type=”Rewrite” url=”/index.php/{R:1}” appendQueryString=”true”/>
</rule>
</rules>
</rewrite>

Share Button

Leave a Reply

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