使用 CodeIgniter 托管时遇到问题
我是 CI 新手。这段时间我一直在我的本地主机上做我最近的项目。我选择 CodeIgniter 和 Doctrine 作为我的数据库框架。
我的本地主机规格是:
Windows 7 Wampserver 2.0
我还在我的 apache 中启用了 rewrite_module 。
从一开始,我的本地主机上的 CI 和 Doctrine 一切都运行良好。我设法完成了我的项目,并很高兴地等待移植我的第一个项目并将其上传到我的 bluehost 帐户的子目录。
在传输文件之前,我通过填写所需的值更改了 config.php 和 database.php。
但是在我将文件(以及 .htaccess)上传到我的托管解决方案提供商之后,除了 404 错误之外什么也看不到(这是来自 codeigniter 类,而不是我的托管解决方案页面)。我一直得到这个。我尝试了多种选择,但我无法弄清楚这是什么意思。我确信 index.php 正在被调用,当它尝试路由到默认控制器(在我的例子中是“home”)时,它会因某种原因失败。
我的本地主机中的目录结构
PathtoWamp->www->mysitefolder
我的实时站点 public_html 中的目录结构
(这是我的根文件夹)->mysitefolder
我还可以看到 rewrite_module 已在我的实时服务器上启用(那就是 wat我的托管解决方案 bluehost 说,我想这是真的)
因为我已经超过了截止日期,我想知道一个解决方案。如果你们有任何想法,请告诉我。
提前致谢。
问候, 阿肖克·斯里尼瓦桑。
I am a CI newbie. All this time i have been doing my recent projects on my localhost. I chose CodeIgniter and Doctrine as my database framework.
My local host specs are:
Windows 7
Wampserver 2.0
I also have rewrite_module enabled in my apache.
Right from the beginning everything was working fine with CI and Doctrine on my localhost. I managed to finish my project and was happily waiting to port my first project live and uploaded it to a subdirectory of my bluehost account.
Before transferring the files i changed the config.php and the database.php by filling the required values.
But after i uploaded my files(along with the .htaccess) to my hosting solution provider i could see nothing but the 404 error (This is from codeigniter class and not my hosting solutions page). I keep getting this. I tried multiple options but i am not able to figure what this is all about. I am sure the index.php is getting called and when it tries to route to the default controller (which is 'home' in my case) it fails for some reason.
The directory structure in my localhost
PathtoWamp->www->mysitefolder
The directory structure in my live site
public_html(this is my root folder)->mysitefolder
I could also see that rewrite_module has been enabled with my live server (Thats wat my hosting solution bluehost says and i guess this is true)
Since i am very well past the deadline, i am wondering for a solution. Kindly do let me know if any of you guys have any idea.
Thanks in advance.
Regards,
Ashok Srinivasan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了问题的根源。一直以来,这不是.htaccess,不是httpd.conf,也不是bluehost,不是上帝,不是任何人,但真正的罪魁祸首是Mr.CodeIgniter。
如果您查看位于系统/库内的 Router.php,那么您会在第 88 号处找到一行,
如果您注意到在三元组的末尾,它们会强制对控制器名称执行 strtolower 操作。我删除了该方法,只是通过将行更改为此来让原始名称在此时使用。
好吧,但是这有什么大不了的呢?是的,这现在很有意义。我的本地服务器是安装在 Windows 上的 wamp,而我的生产服务器托管在 Unix 机器上。众所周知,Windows 是一个软家伙,不太在意大小写的敏感度,但 Unix 恰恰相反,它非常讲究。
我的项目中的控制器名称都是大写模式,真正的问题来自这里。我还去了应用程序/配置中的routes.php,在那里我纠正了这个角度的问题。
现在我终于可以托管我的网站了。感谢所有在阅读我的问题后投入精力的人。
问候,
阿肖克·斯里尼瓦桑。
I found out the root of the problem. All this time it was not the .htaccess, not httpd.conf and not bluehost, it was not god not anyone but the real culprit was Mr.CodeIgniter.
If you look at the Router.php located inside system/libraries then you will find a line at number 88 where
if you notice at the end of the ternary they are forcing a strtolower operation on the controller name. I removed that method and simply let the original name be used at this point by changing the line to this.
Ok but what is the big deal here? Yes this makes a lot of sense right now. My local server was wamp installed on Windows and my production server was hosted on an Unix box. Since it is very well known that Windows is a soft guy who does not mind much about case sensitivity but Unix is very particular on the contrary.
The controller names in my project were all in Capitalized mode, the real issue arised from here. Also i went to my routes.php lying in the application/config where i rectified issues of this perspective.
Finally i am able to host my site now. Thanks to all who had put their heads into this after reading my question.
Regards,
Ashok Srinivasan.
我在你的 httpd.conf 中遇到了同样的问题,
你需要找到这样的一行
将其更改为
这就是我所需要的一切
I had the same problem in your httpd.conf
you need to find a line like this
Change it to
Thats all it took for me