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.

9
  • 1
    Provide your routes if available Commented Jan 10, 2018 at 19:01
  • You should have to do this, but does it work if you specify the routes? Also, what is the name of the controller file? Commented Jan 10, 2018 at 19:07
  • 1
    You should configure the server so that localhost points to the folder /what/ever/projects/ci/. Then use `$config['base_url'] = 'localhost'; Commented Jan 10, 2018 at 19:42
  • Just because mod rewrite is enabled doesn't mean you're allowed to use .htaccess files. You need to ensure that apache is configured to Allowoverride = all Commented Jan 10, 2018 at 20:35
  • 1
    localhost/projects/ci/index.php/admin is this working @syed Commented Jan 11, 2018 at 7:25

2 Answers 2

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] 
Sign up to request clarification or add additional context in comments.

5 Comments

still not working
Did you save your controller as "Admin.php"or 'admin.php'. If you save it 'admin.php' then you have to save as "Admin.php".
i save it as admin.php ,
so you have to save as "Admin.php" not as "admin.php".
sure i will save it as "Admin.php" , and let you know
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.