【发布时间】:2017-08-03 13:00:39
【问题描述】:
我在 Ubuntu 17.04 服务器上安装了最新的 Apache、PHP7 和 codeigniter。我已经为它分配了一个本地 IP,比如说 10.20.30.40。
这个 codeigniter 应用程序应该在本地工作,也应该在外部(互联网)工作。
还有一个中间 nginx 服务器(我无法访问)将所有内容从外部(互联网)重定向到我的服务器,所以我使用 xdebug 进行了一些测试和调试:
本地
http://10.20.30.40/ciapp/index.php/test
工作正常
$_SERVER['REQUEST_URI'] = string '/ciapp/index.php/test'
来自互联网
http://www.subdomain.company.xxx/ciapp/index.php/test
不起作用(它会抛出 codeigniter 404 页面)
$_SERVER['REQUEST_URI'] = string '//ciapp/index.php/test'
(注意前面的双斜杠)
另外,我已经测试了以下
http://10.20.30.40//ciapp/index.php/test
(注意故意使用双斜线)没用,得到 CI 的 404
我可以用 REQUEST_URI 做些什么,让它从外部工作吗?或者可能是另一个问题...?
PS:其他地方建议的配置:
$config['base_url'] = $_SERVER['HTTP_HOST'] == '10.20.30.40' ? 'http://10.20.30.40/ciapp/' : 'http://www.subdomain.company.xxx/ciapp/';
【问题讨论】:
-
你的本地网络服务器是在windows下运行,而你的live服务器是在linux上运行吗?
-
@TimBrownlaw codeigniter 安装在具有静态 IP 的 Ubuntu 服务器中。本地 url 指向这个服务器,live url 也指向这个 Ubuntu 服务器,不同的是只有来自互联网的传入流量被另一个服务器(不知道操作系统)处理 nginx
-
先检查 PHP 和 Apache 日志。
标签: php apache codeigniter nginx url-routing