Codeigniter - how to remove the index.php from url?

Viewed 8457

I have following structure of my project

/system
/applications
  /cache
  /core
  /helpers
  /hook
  /language
  /libraries
  /logs
  /third_party
  /admin-panel
     /config
     /controllers
        welcome.php
        dashboard.php
     /errors
     /models
     /views
        welcome.php
        dashboard.php
  /user-panel
     /config
     /controllers
            welcome.php
            dashboard.php
     /errors
     /models
     /views
        welcome.php
        dashboard.php
/admin
  index.php
index.php

My index.php inside my project folder has user-panel as my application folder and index.php in admin folder has admin-panel as my application folder.

I have inserted this line $route['default_controller'] = "welcome"; $route['welcome'] = 'welcome'; in routes.php inside both user-panel and admin-panel

I can access welcome controller of my both user-panel and admin-panel by using http://localhost/myproject and http://localhost/myproject/admin

but i cannot access my dashboard controller by using http://localhost/myproject/dashboard or http://localhost/myproject/admin/dashboard

my dashboard controller is accessible by using http://localhost/myproject/index.php/dashboard or http://localhost/myproject/admin/index.php/dashboard

But i dont want index.php included in my url. I want to remove it. I have also tried by using .htaccess inside my admin folder. I write following line in this

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

but this didn't work for me. It give 404 not found CI error. I have also enabled mod_rewrite by changing AllowOerride None to AllowOverride All in httpd.conf. Please tell me what should i do to remove index.php and where should i place my .htaccess files in my project directory.

4 Answers
Related