我无法访问我的控制器中的其他功能,直到我将index.php?
添加到url。我可以直接访问任何控制器的index()
功能,但不能访问其他功能。我检查了其他相关问题,但问题仍然存在。我也尝试将所有控制器添加到routes.php
但仍然失败。无法访问控制器Codeigniter的其他功能
HTACESS
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|include|style\.css|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
CONFIG
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['base_url'] = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . preg_replace('@/[email protected]', '', dirname($_SERVER['SCRIPT_NAME'])) . '/';
$config['base_path'] = $_SERVER['DOCUMENT_ROOT'] . preg_replace('@/[email protected]', '', dirname($_SERVER['SCRIPT_NAME'])) . '/';
BLOG控制器
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Blog extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->database();
}
public function index()
{
$data['page_name'] = 'blog';
$this->load->view('pages/index', $data);
}
public function news()
{
$data['page_name'] = 'news';
$this->load->view('pages/index', $data);
}
}
URL
http://localhost/tsb/blog // This works fine
http://localhost/tsb/blog/news // only works when i add index.php? to the url
谢谢你是这个问题 – Mysterio4