【问题标题】:codeigniter application works on hostgator but not another web hostcodeigniter 应用程序适用于 hostgator,但不适用于其他网络主机
【发布时间】:2013-09-24 18:02:05
【问题描述】:

我有一个在我的 hostgator 托管域上完美运行的 codeigniter 应用程序。

我已配置 .htaccess 和 config.php 以从 URL 中删除 index.php。如前所述,这是 100% 工作的。我现在需要使用 Afrihost 将应用程序从我的 hostgator 服务器移动到南非的本地服务器。

修改后的htaccess和config文件如下:

我的 htaccess 文件是:

RewriteEngine on
RewriteBase /

# Prevent CI index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

# Prevent user access to the CI system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L] 

# Prevent user access to the CI application folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

我的 config.php 文件是:

$config['base_url'] = 'http://logicoportal.co.za';
$config['index_page'] = '';
// let me know if you need to see any other setting

当我尝试浏览域 http://www.logicoportal.co.za 时,我收到错误 This page can't be displayed

如果我浏览到我的 ion auth 控制器,http://logicoportal.co.za/auth/login 我会收到 404 错误 The webpage cannot be found

如果我浏览到完整的 codeigniter 默认路径,http://logicoportal.co.za/index.php/auth/login 我会收到错误 This page can't be displayed

我假设这是一个 htaccess 配置错误,但我不确定如何更正。读了很多没有运气的文章。或者,codeigniter 中是否有其他配置设置来支持这一点?

我已经与新的托管公司 Afrihost 进行了交谈,他们说在这方面他们无能为力。

任何建议/方向将不胜感激。

一如既往的感谢。

【问题讨论】:

  • 我同意这可能是一个 htaccess 问题。服务器规格(apache、php 版本等)有什么区别?您可以访问服务器上的任何网页吗?如果您尝试只访问 /index.php 或添加一个简单的 /index.html 文件怎么办?即使您的支持不支持您,他们也可以提供您的 apache 配置和/或错误日志。
  • 是否在其他网络主机上启用了 mod 重写??
  • 您是否在 index.php 文件中打开了错误报告?另外,你设置了什么样的路线?
  • 两台服务器的 Apache 版本均为 2.2.23。旧服务器上的 PHP 版本是 5.2.17,新版本是 5.3.20。谢谢
  • 路线是标准的,只是标准。 $route['default_controller'] = "auth"; $route['404_override'] = '';

标签: .htaccess codeigniter


【解决方案1】:

工作解决方案: htaccess 文件以删除共享主机服务器上的 index.php

DirectoryIndex index.php
RewriteEngine on

RewriteCond %{REQUEST_URI} !^(index\.php|\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) ./index.php [L]

【讨论】:

  • @Smudger 感谢您的解决方案,我吓坏了。但是您的解决方案效果很好
【解决方案2】:

尝试删除? in:

RewriteRule ^(.*)$ /index.php?/$1

原来如此:

RewriteRule ^(.*)$ /index.php/$1

【讨论】:

  • 您好,感谢您的宝贵时间。我确实尝试过,没有任何变化。还有其他想法吗?谢谢,
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-12
  • 1970-01-01
  • 1970-01-01
  • 2011-02-16
  • 2017-02-23
相关资源
最近更新 更多