A. .htaccess文件必须放在CI的根目录下和index.php文件在同一目录。php
(加载后,我出现过问题!css和js不能正常加载!后来才发现须要定义|js|css)css
.htaccess 文件的内容以下:apache
RewriteEngine onapp
#RewriteCond $1 !^(index\.php|images|robots\.txt)ide
RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)spa
RewriteRule ^(.*)$ /CI203/index.php/$1 [L]ci
//CI203为目录,若是ci直接放在根目录。路径就是/index.php/$1 [L]it
有朋友对我上面的设置作出了更正。能够参考下。io
RewriteEngine onmodule
RewriteBase /ci213new
RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
B.在apache配置上,注意httpd.conf文件里:
一、//开启rewrite
LoadModule rewrite_module modules/mod_rewrite.so
二、//开启 .htaccess
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
另外,注意几个文件:
application\config\routes.php—这个文件设置初始加载的默认控制器文件(controller)
application\config\config.php—这个文件设置初始配置,可是,自打我去掉index.php后,$config['index_page'] = ‘index.php’;–这个貌似再也不起做用了。为空也木事。。。