dongnanman9093 2015-04-08 00:41
浏览 45
已采纳

Codeigniter显示在Hostgator上找不到404页面

I'm currently testing my Codeigniter Project on my own Hostgator account. The project works well on my WAMP server but it shows a 404 Page Not Found error when online on Hostgator. I've tried playing around with the file permissions on FTP to playing around with the .htaccess file. The current site can be viewed here: www.test.jeffreyteruel.com.

Here's a look at my .htaccess file:

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

My current file structure:

-application
-assets (css/js/img files) 
-cgi-bin(from the server) 
-system
-uploads
-.htaccess
-index.php

Here's my current config.php info:

$config['base_url'] = 'http://test.jeffreyteruel.com'; 
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

The default controller on the route.php file is: $route['default_controller'] = 'main';

Main Controller (main.php):

<?php defined('BASEPATH') OR exit('No direct script access allowed');
   class Main extends CI_Controller {
      public function __construct() 
      { 
         parent::__construct(); 
         //insert model here    
         $this->load->model('main_model'); 
         date_default_timezone_set('Asia/Manila');       
       } 
      public function index()
      { 
        $content['main_content'] = 'home/home'; 
        $this->load->view('main',$content);
      } 
  ...  
  ?> 

Any help to get the site showing properly would be appreciated.

  • 写回答

1条回答 默认 最新

  • dqthn68688 2015-04-08 01:14
    关注

    I have CI running on a subdomain on Hostgator and I recall a slight struggle getting it working but as I'm old I've got a memory like a.... Hmmm can't remember!

    My Simplified .htaccess is

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

    Addition:

    In your config.php

    $config['base_url'] = 'http://test.jeffreyteruel.com';      
    

    Add the trailing /

    $config['base_url'] = 'http://test.jeffreyteruel.com/';
    

    UPDATE:

    With Codeigniter 3 All Class names need to be Capitialized - First letter Uppercased ( ucfirst ). Refer to : codeigniter.com/userguide3/general/styleguide.html#file-naming

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因