官網給的訪問數據庫讀取數據並顯示的例子:
http://codeigniter.org.cn/user_guide/tutorial/news_section.html
按照例子增加代碼完成後,訪問url : www.xxx.com/index.php/news
明明訪問的是news/view,每次都還得帶上index.php,看着就蛋疼。。。。。。
因此有了本文: 移除 URL 中的 index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
在上面的例子中,除已存在的目錄和文件,其他的 HTTP 請求都會經過你的 index.php 文件。
註解:這些規則並不是對所有 Web 服務器都有效。
註解:確保使用上面的規則排除掉你希望能直接訪問到的資源。
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
# AllowOverride None
# 允許.htaccess文件起作用
AllowOverride All