从 Internet 加载应用时,Codeigniter REQUEST_URI 获取错误值

Codeigniter REQUEST_URI gets wrong value when app loaded from Internet

我已经在 Ubuntu 17.04 服务器上安装了最新的 Apache、PHP7 和 codeigniter。我已经为它分配了一个本地 IP,比方说 10.20.30.40 .
此 codeigniter 应用应在本地运行,也应在外部(互联网)运行。 还有一个中间 nginx 服务器(我无法访问)将所有内容从外部(Internet)重定向到我的服务器,所以我用 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/'; 

尝试以 url 为基础

$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = "$root";

最后通过设置uri_protocol = PATH_INFO

解决

文件: application/config/config.php

$config['base_url'] = $_SERVER['HTTP_HOST'] == '10.20.30.40' ? 'http://10.20.30.40/ci/' : 'http://www.subdomain.company.xxx/ciapp/'; 
$config['index_page'] = '';
$config['uri_protocol'] = 'PATH_INFO'; 

文件:.htaccess(从url中删除index.php)

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]

现在它在本地完美运行并从 Internet 加载