【发布时间】:2023-03-11 22:54:01
【问题描述】:
我的代码点火器有问题,我有以下代码(user_stats.php):
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class User_stats extends MX_Controller
{
function __construct() {
parent::__construct();
}
function user_stats() {
echo "Hello";
}
function detect_location() {
echo "World";
}
}
如果我通过 url 调用该方法,例如http://test/user_stats/detect_location 我得到了输出 World,但是当我加载 http://test/user_stats/user_stats 时,我得到一个错误 404 页面。我检查了日志,出于某种原因,请求是针对http://test/user_stats/index(尝试加载http://test/user_stats/user_stats 时)。我的 htaccess 文件有以下代码:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
配置文件配置为:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
任何解决此问题的帮助将不胜感激。
谢谢
【问题讨论】:
标签: .htaccess codeigniter http-status-code-404 config