以下问题都容易解决,在此简述
1,打开apache的httpd.conf,开启rewrite_module,并且将AllowOverride None改为AllowOverride None。
2,在项目中,和index.php以及system文件夹同级的目录中,新建.htaccess文件,并写入一下代码
<IfModule mod_rewrite.c>RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php/$1 [L]</IfModule>
这时,如果在浏览器访问首页,比如项目名为citest,当输入的url为
http://localhost/citest/Index/index时,会出现
No input file specified.
此时,只要将上述代码第四行中的
RewriteRule ^(.*)$ index.php/$1 [L]
修改为
RewriteRule ^(.*)$ index.php?/$1 [L]
即可,即在index.php与/之间添加一个?,这样就能够正常访问了。
不过在使用辅助函数site_url()和base_url()时,两个还是不太一样,
使用site_url时的路径为http://localhost/citest/index.php
使用base_rul时的路径为http://localhost/citest/
如果要去掉site_url中的路径,则在config.php中,将
$config['index_page'] = 'index.php';
修改为
$config['index_page'] = '';
即可
这样无论是site_url还是base_url的路径都为http://localhost/citest/