Home >Backend Development >PHP Tutorial >使用codeigniter出现404问题
各位好,初使用codeigniter出现了如下问题:
1、windows xp下运行正常,linux下运行出现404错误。
2、访问主页可以显示(http://ip地址/项目名/或http://ip地址/项目名/index.php/index),但是点登录时(http://ip地址/项目名/index/login)出现404错误,index控制器中是存在public的login方法。
3、linux环境为red hat 企业版5 ,apache为2.0.64,php为5.4.3 apache配置了rewrite也 加了path info
尝试过修改config.php中的uri_request 为各个可能的值(query_string,auto等)现象依旧。
看codeigniter的日志似乎login.php已经发送到浏览器了,但是为什么还是404呢
同样的程序在windows下没有问题,请问大家问题可能出在哪里呢?谢谢!
附codeigniter日志:
DEBUG - 2012-06-01 09:42:54 --> Config Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Hooks Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Utf8 Class Initialized
DEBUG - 2012-06-01 09:42:54 --> UTF-8 Support Enabled
DEBUG - 2012-06-01 09:42:54 --> URI Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Router Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Output Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Security Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Input Class Initialized
DEBUG - 2012-06-01 09:42:54 --> XSS Filtering completed
DEBUG - 2012-06-01 09:42:54 --> Global POST and COOKIE data sanitized
DEBUG - 2012-06-01 09:42:54 --> Language Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Loader Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Controller Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Helper loaded: form_helper
DEBUG - 2012-06-01 09:42:54 --> Form Validation Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Session Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Helper loaded: string_helper
DEBUG - 2012-06-01 09:42:54 --> Encrypt Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Database Driver Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Session routines successfully run
DEBUG - 2012-06-01 09:42:54 --> DX Auth Initialized
DEBUG - 2012-06-01 09:42:54 --> Session class already loaded. Second attempt ignored.
DEBUG - 2012-06-01 09:42:54 --> Config file loaded: application/config/dx_auth.php
DEBUG - 2012-06-01 09:42:54 --> Language file loaded: language/japanese/dx_auth_lang.php
DEBUG - 2012-06-01 09:42:54 --> Model Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Model Class Initialized
DEBUG - 2012-06-01 09:42:54 --> Model Class Initialized
DEBUG - 2012-06-01 09:42:54 --> utilityies class already loaded. Second attempt ignored.
DEBUG - 2012-06-01 09:42:54 --> Helper loaded: url_helper
DEBUG - 2012-06-01 09:42:54 --> Config file loaded: application/config/access_limit.php
ERROR - 2012-06-01 09:42:54 --> Severity: Notice --> Undefined variable: message /usr/local/apache2/htdocs/tab/application/views/login.php 44
DEBUG - 2012-06-01 09:42:54 --> File loaded: application/views/login.php
DEBUG - 2012-06-01 09:42:54 --> Final output sent to browser
DEBUG - 2012-06-01 09:42:54 --> Total execution time: 0.0547
先尝试一下这样是否可以
http://ip地址/项目名/index.php/index/login
http://ip地址/项目名/index.php/login
回老大:
http://ip地址/项目名/index.php/index/login 可以访问
http://ip地址/项目名/index.php/login 不可以访问
请问我要如何修改才能使得http://ip地址/项目名/index/login 可以访问呢,谢谢!
我将config.php中的index_page设置为index.php之后http://ip地址/项目名/index.php/index/login会自动出现,windows下index_page是没有设置的但是http://ip地址/项目名/index/login 可以访问。
如果
http://ip地址/项目名/index.php/index/login 可以访问
http://ip地址/项目名/index/login 不可以访问
那就是你的重写规则不对,请检查一下
两者的区别在于,后者需要隐藏 index.php 这个文件名
window 下的应写作
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
linux 下应该也是一样的,请核实
建议先确认一下application/errors/下的log,我遇到的问题的由于controllers下的文件名含有大写字母,在linux下不识别导致的 ,CI的框架好像主张类名全部小写