CodeIgniter - 找不到控制器

CodeIgniter - Controller not found

我知道这个问题已经被问过很多次了,相信我,我已经打开它们并按照步骤操作,但它仍然对我有帮助。 css也乱了(http://anakpanti.com/ab-cargo/)

我有 CI 项目,它在我的本地主机上工作,但在我将它移至虚拟主机后,找不到控制器(默认控制器除外)。

在此服务器上找不到请求的 URL /ab-cargo/controllers_aboutus/。 此外,在尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误。

这是我做了什么:

Change.htaccess 代码如下:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond  !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
</IfModule>

这就是所有的步骤。

哦,我知道问题了。

项目中应该有2个.htaccess文件。

首先,在根文件夹

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond  !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
</IfModule>

并且也在 应用程序文件夹中:

<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>

这是您正确的 baseurl (http://anakpanti.com/ab-cargo/)。 S 添加 rewiteBase /ab-cargo。 使用这个 .htaccess

RewriteEngine On
RewriteBase /ab-cargo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]

在 header 中包含样式 sheet 时,在 href 标签中使用 base_url()

<link rel="stylesheet" href="<?php echo base_url();?>CSS/main.css" type="text/css">