0

I am stuck with removing index.php.

mod Rewrite is enabled in my apache, I have checked earlier

my url

http://localhost/projects/ci/admin

Here is my controller

class Admin extends CI_Controller{
    public function index()
    {
        echo "Admin Function";
    }
}

here is my .htaccess file, which I copied from Codeigniter user_guide

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

done everything to run it:

changed $config['base_url'] = ''; to $config['base_url'] = 'http://localhost/projects/ci/';

changed $config['uri_protocol'] = 'REQUEST_URI'; to $config['uri_protocol'] = 'AUTO'; and vice-versa

also $config['index_page'] = 'index.php'; to $config['index_page'] = ''; with the help of stackoverflow solutions but failed to do so.

Vickel
  • 7,879
  • 6
  • 35
  • 56

2 Answers2

0

in .htaccess file copy the below code and save it and then try it

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

I'm sharing my configuration on an application im developing (with CI)

In the file ../application/config/routes.php, line 53 on CI v3.1.6

$route['default_controller'] = 'MyDefaultController';

.htaccess

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

As far as i know does not really matter if u remove index.php if all ur system files are allocated on the ../public_html folder on your server, if not, u should keep it and make the changes so CI "knows" where to find system, application and views files.

Also if u delete index.php and don't set the the default controller on routes.php, (sorry about my english here) CI will not find its "index page".

In short, check the default controller on routes.php Hope it helps.

Francisco Hahn
  • 435
  • 5
  • 10