Adam
Adam

Reputation: 9049

Codeigniter: getting clean urls and removing index.php

Well I'm not really sure how you guys implement mod_rewrite with codeigniter, and I'm not even sure If I need to do that right now. What I want is to get rid of the index.php that trails the root directory, so eliminate it from www.mydomain.com/index.php/mycontroller and just have www.mydomain.com/mycontroller/

Upvotes: 0

Views: 5584

Answers (3)

nageeb
nageeb

Reputation: 2042

In addition to what everyone above said about .htaccess, you also have to set

$config['index_page'] = 'index.php';

to

$config['index_page'] = '';

in your /application/config/config.php file

Upvotes: 4

Pramod Kumar Sharma
Pramod Kumar Sharma

Reputation: 8012

you can place this in .htaccess to remove index.php from url

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

Upvotes: -1

Dan Teesdale
Dan Teesdale

Reputation: 1863

You can hide your index.php by modifying your .htaccess file. For example,

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

You can find out more about CodeIgniter URLs here: http://codeigniter.com/user_guide/general/urls.html

Upvotes: 2

Related Questions