今天学习CodeIgniter简称CI的第一天,记录下学习心得。php
CI中国https://codeigniter.org.cn/user_guide/general/urls.html?highlight=url 这里有介绍html
example.com/class/function/ID
默认状况,你的 URL 中会包含 index.php 文件:apache
example.com/class/function/ID
一、
若是你的 Apache 服务器启用了 mod_rewrite ,你能够简单的经过一个 .htaccess 文件(放在index.php同级目录)服务器
再加上一些简单的规则就能够移除 index.php 了。下面是这个文件的一个例子, 其中使用了 "否认条件" 来排除某些不须要重定向的项目:app
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
在上面的例子中,除已存在的目录和文件,其余的 HTTP 请求都会通过你的 index.php 文件。ide
或者不使用.htaccess 直接在apache配置文件中函数
<Directory />
Require all granted
AllowOverride all
Order allow,deny
Allow from all
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>codeigniter
二、学习