【问题标题】:Godaddy - Codeigniter - No input file specified on serverGodaddy - Codeigniter - 服务器上没有指定输入文件
【发布时间】:2016-09-16 04:39:11
【问题描述】:

我刚刚在 godaddy 的子文件夹中上传了我的演示项目。当我打开网站网址 example.com/demo 主页工作正常,但当我尝试打开内页时,我的网址看起来像 example.com /demo/index.php/home/overview 它显示 未指定输入文件

注意:CodeIgniter 版本 -3.0.0 和服务器 GoDaddy

URL Look Like : example.com/demo/

这是我的 .htaccess 文件

 <IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

我的配置文件看起来像

<?php defined('BASEPATH') OR exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
*/


$config['document_root'] = $_SERVER['DOCUMENT_ROOT']."/demo";
$config['http_host']    = "http://".$_SERVER['HTTP_HOST']."/demo";
$config['base_url'] = "http://".$_SERVER['HTTP_HOST']."/demo/index.php/";
$config['front_base_url'] = "http://".$_SERVER['HTTP_HOST']."/demo/index.php";
$config['base_url_views'] = "http://".$_SERVER['HTTP_HOST']."/demo/application/views/";
$config['upload'] = $_SERVER['DOCUMENT_ROOT']."/demo/upload/";



/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
*/
$config['index_page'] = 'index.php';

/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
*/
$config['uri_protocol'] = 'REQUEST_URI';

/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
*/
$config['url_suffix'] = '';

/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
*/
$config['language'] = 'english';

/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
*/
$config['charset'] = 'UTF-8';

/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
*/
$config['enable_hooks'] = FALSE;

/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
*/
$config['subclass_prefix'] = 'MY_';

/*
|--------------------------------------------------------------------------
| Composer auto-loading
|--------------------------------------------------------------------------
*/
$config['composer_autoload'] = FALSE;

/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

/*
|--------------------------------------------------------------------------
| Enable Query Strings
|--------------------------------------------------------------------------
*/
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';

/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
*/
$config['log_threshold'] = 0;

/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
*/
$config['log_path'] = '';

/*
|--------------------------------------------------------------------------
| Log File Extension
|--------------------------------------------------------------------------
*/
$config['log_file_extension'] = '';

/*
|--------------------------------------------------------------------------
| Log File Permissions
|--------------------------------------------------------------------------
*/
$config['log_file_permissions'] = 0644;

/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
*/
$config['log_date_format'] = 'Y-m-d H:i:s';

/*
|--------------------------------------------------------------------------
| Error Views Directory Path
|--------------------------------------------------------------------------
*/
$config['error_views_path'] = '';

/*
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------

*/
$config['cache_path'] = '';

/*
|--------------------------------------------------------------------------
| Cache Include Query String
|--------------------------------------------------------------------------
*/
$config['cache_query_string'] = FALSE;

/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
*/
$config['encryption_key'] = '';

/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------

*/
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;

$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
*/
$config['cookie_prefix']    = '';
$config['cookie_domain']    = '';
$config['cookie_path']      = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']  = FALSE;

/*
|--------------------------------------------------------------------------
| Standardize newlines
|--------------------------------------------------------------------------
*/
$config['standardize_newlines'] = FALSE;

/*
|--------------------------------------------------------------------------
| Global XSS Filtering
|--------------------------------------------------------------------------
*/
$config['global_xss_filtering'] = FALSE;

/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
*/
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();

/*
|--------------------------------------------------------------------------
| Output Compression
|--------------------------------------------------------------------------
*/
$config['compress_output'] = FALSE;

/*
|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
*/
$config['time_reference'] = 'local';

/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
*/
$config['rewrite_short_tags'] = FALSE;

/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
*/
$config['proxy_ips'] = '';

【问题讨论】:

  • $config['index_page'] = 'index.php'; 将此替换为$config['index_page'] = '';并尝试!删除 index.php
  • thanx 但没用。错误:404 页面未找到。!!
  • 我在更改 .user.ini 文件时发生了这种情况,您是否更改了该文件中的任何内容?
  • 没有没有改变任何东西..
  • 请不要标记垃圾邮件。如果您使用 CodeIgniter v3,则不要使用 CodeIgniter v2 标签。已编辑。

标签: php codeigniter codeigniter-3


【解决方案1】:

基本网址应该是

$config['base_url'] = "http://".$_SERVER['HTTP_HOST']."/demo/";

而 htaccess 文件需要这个改变

RewriteBase /demo/

【讨论】:

    【解决方案2】:

    .htaccess 文件中试试这个代码:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    

    【讨论】:

      【解决方案3】:

      尝试将其放入您的 .htaccess 文件中:

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

      【讨论】:

        【解决方案4】:

        谢谢大家的回复。终于我得到了解决方案。我只是在 config.php 文件中更改了我的配置文件设置。

        $config['index_page'] = 'index.php?'; // replace with (?) mark
        $config['uri_protocol'] = 'QUERY_STRING';
        

        我的 .htaccess 文件是

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

        非常感谢。希望对大家有用。

        【讨论】:

        • 从漂亮的 URL 更改为查询字符串几乎不是您原始问题的实际解决方案。见answer by Tpojka
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-02-06
        • 2011-09-01
        • 1970-01-01
        • 2017-08-12
        • 1970-01-01
        • 2015-09-18
        • 1970-01-01
        相关资源
        最近更新 更多