Ekky
Ekky

Reputation: 790

Want to remove Index.php from Codigniter URL

I want to remove index.php from code igniter URL ,I had created .htaccess file and stored it in application folder parallel to index.php and also remove

$config['index_page'] = '';

from config.php.

Code in .htaccess file, which is not working :

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /WCPM/index.php/$1 [L] 

URL of the project is:

localhost/WCPM/index.php

NOTE:Please Don't mark this question as duplicate because I had already tried lots of solution for the same but none of them works for me , so at last I am asking this question here for the solution

Upvotes: 0

Views: 156

Answers (5)

Muddassar Ahmad
Muddassar Ahmad

Reputation: 516

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|imgs)
RewriteRule ^(.*)$ index.php/$1 [L]  
RewriteRule ^media/imatges/([0-9]+)/([A-Za-z0-9-]+).jpg?$ imgs/$1  [T=image/jpeg,L]
<Files "index.php">
AcceptPathInfo On
</Files>

This is the entire recommended code to put at the start of your .htaccess file

Upvotes: 0

Praburam S
Praburam S

Reputation: 165

In Config.php Change as Follows

$config['index_page'] = '';
$config['base_url'] = 'http://localhost/WCPM/';

And Create .htaccess file like

RewriteEngine on
RewriteCond $1 !^(index\.php|[WCPM])
RewriteRule ^(.*)$ /WCPM/index.php/$1 [L]

and Save this in Root Folder [WCPM] i.e. near Application Folder.

For More Details Refer the CI Manual @ http://ellislab.com/codeigniter/user-guide/general/urls.html

Upvotes: 1

Dipesh Parmar
Dipesh Parmar

Reputation: 27364

First of all, change following setting in your config file.

$config['index_page'] = '';

and then, replace .htaccess file located at your project root folder not in the application folder with the following code..

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

Upvotes: 0

Abhishek Kannan
Abhishek Kannan

Reputation: 988

Enable mod_rewrite module in apache.

If that doesnt work or mod_rewrite is already enabled, try this

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

</IfModule>

Upvotes: 0

Related Questions