用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3949|回复: 3
收起左侧

[已解决] 为什么我不能访问index.php/blog/,错误为404

[复制链接]
发表于 2010-5-10 13:27:05 | 显示全部楼层 |阅读模式
本帖最后由 rivercg 于 2010-5-11 03:14 编辑

按照教程添加了blog.php,添加了 index() 函数显示hello world,可为什么我不能访问

http://localhost/phpweb/index.php/blog/

我的ci安装在E:\PhpWeb\CodeIgniter_1.7.2目录,使用IIS ISAPI,重定向到http://localhost/phpweb/.

http://localhost/phpweb/index.php是正常的,能够正常显示welcome page。
并且routes.php修改$route['default_controller'] = "blog"的情况下,也能正常显示http://localhost/phpweb/index.php。

但http://localhost/phpweb/index.php/welcome/和http://localhost/phpweb/index.php/blog/也都不行,错误都是404,"The page cannot be found".
发表于 2010-5-10 16:42:04 | 显示全部楼层
去掉url里最后的/ ,试试这样访问.
http://localhost/phpweb/index.php/blog
 楼主| 发表于 2010-5-10 23:21:01 | 显示全部楼层
。。。。显然不行嘛
不是说http://localhost/phpweb/index.php/class/funid/...吗?
有谁知道是什么配置问题吗?
 楼主| 发表于 2010-5-11 03:12:06 | 显示全部楼层
搞了半天最终是因为iis isapi的问题

参考了
http://codeigniter.org.cn/forums ... d=415&highlight=iis

最终的解决方案(后来重定向目录到http://localhost/CodeIgniter/)
(1)config.php设置
$config['base_url']        = "http://localhost/CodeIgniter/";

(2)安装了ISAP_Write lite 2.6,在其httpd.ini中添加
RewriteRule ^/CodeIgniter/index.php/(.*) /CodeIgniter/index.php?/$1
RewriteRule ^/CodeIgniter/(?!index.php)(.*) /CodeIgniter/index.php?/$1

对于(2),也可参考
http://buddylindsey.com/ionics-isapi-rewrite-module-with-code-igniter/
安装开源的IonicIsapiRewriter,然后在其bin目录中添加IIRF.ini,并设置
RewriteEngine On
RewriteRule ^/CodeIgniter/index.php/(.*) /CodeIgniter/index.php?/$1
RewriteRule ^/CodeIgniter/(?!index.php)(.*) /CodeIgniter/index.php?/$1

最终可以访问:
http://localhost/CodeIgniter/index.php
http://localhost/CodeIgniter/index.php/blog/
http://localhost/CodeIgniter/blog/

本版积分规则