我一直在Windows 7上的XAMPP中开发CodeIgniter应用程序。该应用程序在本地按预期运行,但在上传时
无法运行。默认控制器(ShowStadium)具有以下方法:- 索引()- 显示()
当通过基本路径调用时,索引加载正常,但在直接调用时都不会加载:
/pathToApp/ShowStadium/或/pathToApp/ShowStadium/index 或 pathToApp/ShowStadium/show
收到的错误是代码点火器 404 消息。
代码点火器实例当前位于 2 个子文件夹中。我的 .htaccess 文件:
RewriteEngine On
# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/
RewriteBase /proj/groundtweet/
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
我尝试过的事情:
- 控制器文件均为小写。
- 两个安装的基本路径都是正确的。
- 尝试了各种uri_protocol选项
- 索引.php已从路径中删除。
任何帮助将不胜感激,因为我无法具体找到这个问题的答案,而且它可能很简单,这令人沮丧。
如果我在这里错过了任何细节,我们深表歉意。
谢谢。
试试下面的代码,把它粘贴到 .htaccess 文件中。 将此文件放在项目文件夹下如果您的项目文件夹是 Groundtweet。将文件粘贴到此文件夹下。
RewriteEngine on
RewriteCond $1 !^(index'.php|images|robots'.txt)
RewriteRule ^(.*)$ /proj/groundtweet/index.php/$1 [L]
我希望这对你有所帮助..
转到 application/config/config.php 并更改
$config['uri_protocol'] = 'AUTO';
使用以下选项之一(它们在此配置上注释):
'PATH_INFO' Uses the PATH_INFO
'QUERY_STRING' Uses the QUERY_STRING
'REQUEST_URI' Uses the REQUEST_URI
'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
其中之一应该适合您
感谢您的所有回答,最后这是一个区分大小写的问题。
控制器文件名为小写 (showstadium.php),但在 Pascal case (ShowStadium) 中以表单操作引用。
似乎对于默认控制器/操作,CodeIgniter 可以解决此问题(我还没有看过胆量,所以我只是在这里做一个假设),但是当直接调用时,文件名必须与 url 大小写匹配 - 在 linux 服务器上。