繁体   English   中英

没有index.php,Codeigniter无法访问控制器

[英]Codeigniter cannot access controller without index.php

我本地的xampp codeigniter项目的URL是http://localhost/ci_yudeesh/index.php,但是后来想从URL中删除index.php部分,因此我按照用户指南中的步骤进行操作。

之后,我可以使用URL http:// localhost / ci_yudeesh /访问没有index.php的项目。

我有一个名为Home的控制器,可以使用http://localhost/ci_yudeesh/index.php/home进行访问,但是当尝试使用http:// localhost / ci_yudeesh / home进行访问时,会出现此错误:

错误图片

这是我的配置:

$config['base_url'] = 'http://localhost/ci_yudeesh/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

这是我的.htaccess:

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

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

这是我的路线:

$route['default_controller'] = 'Home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

有人可以帮我解决这个问题吗? 我尝试了所有其他类似类型问题的答案,但没有一个起作用。

应用程序文件夹中删除.htaccess并将其放在应用程序文件夹之外,并仅在其中写入以下代码。 如果它不起作用,那么我将给您另一个.htaccess代码。

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

更改.htaccess文件。 从现有文件中删除代码,然后在文件上添加以下代码:

在RewriteEngine上

RewriteCond $ 1!^(index.php | resources | robots.txt)

RewriteBase / ci_yudeesh /

RewriteCond%{REQUEST_FILENAME}!-f

RewriteCond%{REQUEST_FILENAME}!-d

RewriteRule ^(。*)$ index.php?/ $ 1 [L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM