[英]How to separate same directory - controller name in Codigniter
I've got a controller called course and a directory with the same name, and when I request 当我请求时,我有一个名为Course的控制器和一个具有相同名称的目录
my_site/course
my_site /课程
it redirects my to the directory course Instead of controller, how can I redirect to the controller 它将我重定向到目录课程而不是控制器,如何重定向到控制器
PS It's very necessary to keep directory with the same name in my apllication PS在我的应用程序中,保持目录名称相同是非常必要的
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.
通过在根目录中拥有一个与控制器名称相同的目录,您的Web服务器将为该目录提供服务,而不是正常的CodeIgniter路由。
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). 如果绝对要在根目录中包含该文件夹,那么您将需要更改.htaccess文件,以忽略与该目录的目录名称匹配的请求(以及与控制器名称匹配的其他任何请求)。
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 已经有一个答案 ,以及在Drupal网站上的一个很好的例子,我将其放在下面,以防它被移动
=========[ 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 ]=====================
There nativ Ci routing. 有nativ Ci路由。
In config/routes.php 在config / routes.php中
$route['course'] = 'controller/course'; $ route ['course'] ='controller / course';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.