官网https://codeigniter.org.cn/
下载https://codeigniter.org.cn/user_guide/installation/downloads.html
环境:php>=5.3
模式:MVC
一、Controller:application/controllers/Blogs.php
<?php
class Blogs extends CI_Controller
{
public function view($page = 'home')
{
// if (!file_exists(APPPATH . 'views/blogs/' . $page . '.php')) {
// echo '404';
// show_404();
// }
$data['title'] = ucfirst($page);
$this->load->view('templates/header', $data);
$this->load->view('blogs/' . $page, $data);
$this->load->view('templates/footer', $data);
}
}
?>
二、model:application/models/Blogs_model.php
<?php
class Blogs_model extends CI_Model {
public function __construct()
{
$this->load->database();
}
}
?>
//待完善
三、view:application/views/blogs/home.php
<div>
hello blogs home page
</div>
//待完善
四、其他
header:
<html lang="en">
<head>
<title>CodeIgniter Tutorial</title>
</head>
<body>
<h1><?=$title?></h1>
footer:
<em>© 2008-2019</em>
</body>
</html>
Apache设置url取消index.php
编写文件:
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|images|public|assets|robots\.txt) //不转发的类型及目录
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
IIS设置url取消index.php
编写配置文件:
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="OrgPage" stopProcessing="true">
<match url="^(.*)$" />
&nbs