代码之家  ›  专栏  ›  技术社区  ›  Jason Miesionczek

将网站移动到新的主机和域,所有链接呈现主页?

  •  0
  • Jason Miesionczek  · 技术社区  · 14 年前

    我的情况是:

    我的一个客户端有一个基于CodeIgniter的站点,托管在domainA.com上的某个共享主机上。他们想把网站移到一个新的域名和新的主机,我已经做了。我创建了一个新数据库,导出了旧数据库并将其导入到新数据库中,然后在config.php文件中更改了baseurl。网站本身加载正确。

    然而,每当我点击一个形式为“domainB.com/site/someaction”的链接时,它们都只是呈现或重定向到主页。我知道PHP,但没有使用CodeIgniter的经验。我不知道最初是谁创建了这个网站来向他们寻求帮助,所以我希望有人能对可能发生的事情有所了解。

    我可以提供任何其他可能需要的信息来尝试解决这个问题。谢谢。

    更新

    .htaccess:访问:

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

    配置.php:

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    $config['base_url'] = "http://www.bidcleangrow.com/";    
    $config['index_page'] = "";
    $config['uri_protocol'] = "AUTO";
    $config['url_suffix'] = "";
    $config['language'] = "english";
    $config['charset'] = "UTF-8";
    $config['enable_hooks'] = FALSE;
    $config['subclass_prefix'] = 'MY_';
    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
    $config['enable_query_strings'] = FALSE;
    $config['controller_trigger']   = 'c';
    $config['function_trigger']     = 'm';
    $config['directory_trigger']    = 'd'; // experimental not currently in use
    $config['log_threshold'] = 3;
    $config['log_path'] = '';
    $config['log_date_format'] = 'Y-m-d H:i:s';
    $config['cache_path'] = '';
    $config['encryption_key'] = "";
    $config['sess_cookie_name']     = 'ci_session';
    $config['sess_expiration']      = 7200;
    $config['sess_encrypt_cookie']  = FALSE;
    $config['sess_use_database']    = FALSE;
    $config['sess_table_name']      = 'ci_sessions';
    $config['sess_match_ip']        = FALSE;
    $config['sess_match_useragent'] = TRUE;
    $config['sess_time_to_update']  = 300;
    $config['cookie_prefix']    = "";
    $config['cookie_domain']    = "";
    $config['cookie_path']      = "/";
    $config['global_xss_filtering'] = TRUE;
    $config['compress_output'] = FALSE;
    $config['time_reference'] = 'local';
    $config['rewrite_short_tags'] = FALSE;
    $config['proxy_ips'] = '';
    
    
    /* End of file config.php */
    /* Location: ./system/application/config/config.php *
    
    1 回复  |  直到 14 年前
        1
  •  1
  •   Orbling    14 年前

    新域是否有子域“系统”设置?

    RewriteCond %{REQUEST_URI} ^system.*
    

    更新

    经过一番调试后,发现问题是服务器上Apache的一些奇怪的CGI设置没有按照CodeIgniter希望的方式设置CodeIgniter检查的任何变量。

    修改 URI 类方法 _fetch_uri_string() (system/libraries/URI.php:92;v1.7.2) 看看 $_SERVER['ORIG_PATH_INFO'] 直接当存在而不是任何其他变量解决了这个问题。 $_SERVER['SCRIPT_NAME'] 镜像此变量,而不是像CodeIgniter所期望的那样成为其子部分。

    更新2

    我刚刚发现了一个更简单的解决方案。

    改变 $config['uri_protocol'] 在里面 system/application/config/config.php ORIG_PATH_INFO 有同样的效果。是的,我应该有RTFM的,但我从不使用编码器点火器。

    推荐文章