Wednesday, January 28, 2015

Remove index.php from Codeigniter url

<ol>
<li>Open <strong>config.php</strong> from <strong>system/application/config</strong> directory and replace
<strong>$config['index_page'] = “index.php”</strong> by <strong>$config['index_page'] = “”</strong></li>
<li>Create a <strong>“.htaccess”</strong> file in the root of CodeIgniter directory (where the system directory resides), open the file using your favorite text editor, write down the following script and save it:</li>
</ol>
===========================================

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

or

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|assets|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

or do the below one:

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

===========================================

3. In some case the default setting for <strong>uri_protocol</strong> does not work properly. To solve this problem just replace
<strong>$config['uri_protocol'] = “AUTO”</strong> by <strong>$config['uri_protocol'] = “REQUEST_URI”</strong> from <strong>system/application/config/config.php</strong>

And you are done !

if you fail to do this then please <strong>turn on or comment out</strong> mod_rewrite engine from <strong>httpd.conf</strong> file.

No comments:

Post a Comment

Change priority of dual boot OS

Change priority of dual boot OS  (Windows and Linux): Go to your Linux OS, install Grub customizer. Then change priority by up and down arro...