[英]Codeigniter controller not accessible without index.php in URL
我已经尝试过解决之前在这里提出的类似问题,并尝试了几种解决方案,但是它们似乎没有用。
我的localhost
根目录中有一个名为“ projectX”的文件夹,该文件夹是CodeIgniter项目
该项目有一个称为仪表板的控制器。
通过以下链接可访问仪表板:http://localhost/projectX/index.php/dashboard
但是,如果我尝试不使用 index.php
( http:// localhost / projectX / dashboard ),则会显示“未找到”。
这是我的.htaccess文件的样子(该文件在application文件夹外部,在projectX文件夹的根目录中)
RewriteBase /projectX
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*) index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) index.php?/$1 [L]
这是我的配置文件:-
$config['base_url'] = "http://localhost/projectX/";
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
/*
我究竟做错了什么?
检查以下规则:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
并更改此:
$config['uri_protocol'] = "AUTO"
// Replace with
$config['uri_protocol'] = "REQUEST_URI"
资料来源: https : //www.codeigniter.com/userguide3/general/urls.html
在您的.htaccess文件中尝试一下
Options All -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.