代码之家  ›  专栏  ›  技术社区  ›  Enrique

当从互联网加载应用程序时,Codeigniter REQUEST\u URI获取错误值

  •  0
  • Enrique  · 技术社区  · 7 年前

    .
    . 还有一个中介nginx服务器(我无法访问),它将所有内容从外部(互联网)重定向到我的服务器,因此我用xdebug进行了一些测试和调试:

    本地

    http://10.20.30.40/ciapp/index.php/test
    工作正常

    $_SERVER['REQUEST_URI'] = string '/ciapp/index.php/test'
    

    来自Internet

    http://www.subdomain.company.xxx/ciapp/index.php/test

    $_SERVER['REQUEST_URI'] = string '//ciapp/index.php/test'
    

    http://10.20.30.40//ciapp/index.php/test
    没用,拿到了CI的404

    我可以对REQUEST\u URI做些什么,以便它从外部工作吗?或者这是另一个问题。。。?

    PS:其他地方建议的配置:

    $config['base_url'] = $_SERVER['HTTP_HOST'] == '10.20.30.40' ? 'http://10.20.30.40/ciapp/' : 'http://www.subdomain.company.xxx/ciapp/'; 
    
    2 回复  |  直到 7 年前
        1
  •  0
  •   hrishi    7 年前

    将基本url尝试为

    $root = "http://".$_SERVER['HTTP_HOST'];
    $root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
    $config['base_url'] = "$root";
    
        2
  •  0
  •   Enrique    7 年前

    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/$1 [L]