我应该将什么添加到我的htaccess文件或"/application/controllers/Pages.php"文件或"/application/config/routes.php"文件中,以防止CodeIgniter路由器将请求路由到目录中的页面,例如(venus( 例如:我在"example.com"中安装了代码点火器 我希望"www.example.com/venus"就像没有安装代码点火器一样工作
//////////////////////////////////////////////
///application/config/routes.php file is:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$route['venus/(:any)'] = "venus/$1";
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
////////////////////////////////////////
.htaccess file
RewriteEngine on
RewriteCond $1 !^(index.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]
///////////////////////////////////////////////
///application/controllers/Pages.php file
<?php
/**
* Created by PhpStorm.
* User: MIKE
* Date: 2/17/2019
* Time: 9:46 AM
*/
class Pages extends CI_Controller{
public function view($page = "home"){
if($page = "venus/(:any)"){
}
else if(!file_exists(APPPATH.'views/pages/'.$page.'.php')){
show_404();
}
$data['title'] = ucfirst($page);
$this->load->view('templates/header');
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer');
}
}
但问题是 www.example.com/venus/file1.php 仍然路由到我的 404 页面。这就是问题所在
在我不想受影响的目录中创建了一个 .htaccess 文件,并在其中写了文本 RewriteEngine Off