【问题标题】:Problems uploading codeigniter project from localhost to live server将 codeigniter 项目从本地主机上传到实时服务器时出现问题
【发布时间】:2015-07-29 05:00:51
【问题描述】:

我在 codeigniter 中开发了一个项目。现在我想将它从本地主机移动到实时服务器。但是我移动了它,网站第一次打开,当我刷新页面时,它只显示空白页面。我在另一个浏览器中尝试过,也有同样的问题。 30分钟后,当我尝试打开网站时,它第一次打开,然后在刷新网站时再次打开,出现空白页面。

关闭浏览器后再次打开,页面第一次打开,然后刷新后它不起作用,也不会进入其他页面。

我不明白问题出在哪里。请有人帮助我。

【问题讨论】:

  • 不,我使用的是 codeigniter 2.2。
  • 我已经包含了它。实际上,当我第一次打开浏览器并运行我的项目时,它运行良好。但是当我的项目的第一页打开时,之后当我点击一个链接时它不会打开并显示一个空白页。刷新同一页面,也会使该页面变为空白。错误报告也打开了,也没有显示任何错误。
  • 提供您的config.php 的内容,也可以向我们提供您的文件结构。你可以在这里生成一个:FileStructureGenerator.com
  • 我已在以下答案中发布了我的 config.php 文件,因为它太长了我无法在评论中发布它@CodeGodie
  • 没有人回答我的问题。请有人回答我的问题。您的回答将不胜感激。

标签: codeigniter


【解决方案1】:

试试这个 .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.

    ErrorDocument 404 /index.php
</IfModule>

【讨论】:

    【解决方案2】:

    以下是我的 config.php 文件的内容。

    $config['base_url'] = 'http://mysyite/folder/subfolder/';
    
    $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['allow_get_array']      = TRUE;
    $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'] = 4;
    
    $config['log_path'] = '';
    
    $config['cache_path'] = '';
    
    $config['rewrite_short_tags'] = FALSE; 
    

    【讨论】:

    • 以上是我的config.php的内容。 @CodeGodie
    • 能否也提供index.php的内容?
    【解决方案3】:

    这是 index.php 文件。

     switch (dirname(__FILE__)){
    
            case 'C:\wamp\www\ems\public_html' :
                $env = 'development';
                break;
    
            default :
                $env = 'production';
                break;
        }
    
    define('ENVIRONMENT', $env);
    
    
    if (defined('ENVIRONMENT'))
     {
        switch (ENVIRONMENT)
        {
            case 'development':
                error_reporting(E_ALL);
            break;
    
            case 'testing':
            case 'production':
                error_reporting(0);
            break;
    
            default:
                exit('The application environment is not set correctly.');
        }
    }
    
    $system_path = '../system';
    
    $application_folder = '../application';
    

    请有人帮忙,我遇到了很大的麻烦,而且我在这个项目上的时间非常少。 @CodeGodie

    【讨论】:

    • 那么为什么你的索引指向你的系统路径一个目录呢?你移动文件了吗?如果您向我们展示您的文件结构,这将非常有帮助。
    • 那是因为我的系统和应用程序文件夹是一层后退。那没问题。在我看来,问题出在 .htacces 文件中@CodeGodie
    猜你喜欢
    • 2015-07-18
    • 2019-05-08
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-25
    相关资源
    最近更新 更多