今天學習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
二、學習