0

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

Ekky
  • 792
  • 4
  • 14
  • 29

5 Answers5

1

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

Praburam S
  • 155
  • 2
  • 9
0

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>
Abhishek Kannan
  • 988
  • 8
  • 16
0

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
Dipesh Parmar
  • 27,090
  • 8
  • 61
  • 90
0

There is a full article for this at:

http://www.web-and-development.com/codeigniter-remove-index-php-minimize-url/#remove-index-php

John Skoumbourdis
  • 3,041
  • 28
  • 34
0
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

Muddassar Ahmad
  • 516
  • 4
  • 8