1

I've got a controller called course and a directory with the same name, and when I request

my_site/course

it redirects my to the directory course Instead of controller, how can I redirect to the controller
P.S It's very necessary to keep directory with the same name in my apllication

Muhammad Sultan
  • 473
  • 5
  • 19

2 Answers2

1

Does the directory need to be int he root folder, can it not be further down the hierarchy? By having a directory with the same name as your controller in the root directory, your web server is serving up the directory instead of normal CodeIgniter routing.

If it's an absolute must to have the folder in the root, then you would need to change your .htaccess file to ignore requests which match the directory name for that directory (and any others which match controller names).

There's an answer for this already, as well as a good example on the Drupal website which I've put in below in case it gets moved

=========[ start of .htaccess snippet]==========
<IfModule mod_rewrite.c>
    RewriteEngine on
    #
    RewriteCond %{REQUEST_URI} !^/yourDirectoryName
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L,QSA]
</IfModule>
====================[ end ]=====================
Community
  • 1
  • 1
gabe3886
  • 4,235
  • 3
  • 27
  • 31
  • thank you @gabe3886 for your help I tried the solution in this [http://stackoverflow.com/questions/13837538/exclude-folder-from-htaccess] but it didn't help my .htaccess file content `RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] ` I created a a new .htaccess in the folfer that I want to ignore and put `RewriteEngine Off` inside it – Muhammad Sultan May 07 '15 at 16:26
-1

There nativ Ci routing.

In config/routes.php

$route['course'] = 'controller/course';

  • after default routes
Maxim Colesnic
  • 408
  • 1
  • 4
  • 12