1

Hi following are the changes I have made to remove index.php from URL

replaced $config['index_page'] = "index.php"

to $config['index_page'] = ""

then replace $config['uri_protocol'] ="AUTO"

by $config['uri_protocol'] = "REQUEST_URI"

then I added below code in .htaccess file

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

but this isn't working. Any Idea, what is wrong ?

Daniyal Nasir
  • 669
  • 7
  • 22
Paritosh Mahale
  • 1,238
  • 2
  • 14
  • 42
  • check this url :- https://stackoverflow.com/questions/37132494/how-to-remove-the-index-php-from-url-in-codeigniter-project/37133083#37133083 – Nimesh Patel Feb 02 '18 at 09:50

4 Answers4

2

You don't have to edit index.php, replace the content .htaccess file to:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
kamote ulalo
  • 162
  • 5
0

Please try using following code.

RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Herry Pats
  • 11
  • 1
  • 3
0

I dont know but i think the last thing you need to do is on your Apache. httpd.conf

Change

AllowOverride None

To

AllowOverride All

Also may i know where your .htaccess is located?

Riyenz
  • 2,498
  • 2
  • 9
  • 23
0

Place the .htaccess file in the project folder like this:

htdocs/your_project/.htaccess

Try this new code for .htaccess:

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

Don't try to delete the other .htaccess file that is already in your application folder.

Changes in config.php are as follows:

$config['base_url'] = 'http://localhost/your_project_name/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

Don't use:

$config['uri_protocol'] ="AUTO"

Hope it will perfectly work fine for you.

umarbilal
  • 308
  • 4
  • 20