2017-02-21 1 views
0

CodeIgniter: 404 Page Not Found on Live Serverと同じ問題が発生しています。アプリケーション/コントローラの中で、私はそうのようなWelcome.phpを持っている:Codeigniterページにアクセスすると、

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

class Welcome extends CI_Controller { 

    /** 
    * Index Page for this controller. 
    * 
    * Maps to the following URL 
*  http://example.com/index.php/welcome 
* - or - 
*  http://example.com/index.php/welcome/index 
* - or - 
* Since this controller is set as the default controller in 
* config/routes.php, it's displayed at http://example.com/ 
* 
* So any other public methods not prefixed with an underscore will 
* map to /index.php/welcome/<method_name> 
* @see https://codeigniter.com/user_guide/general/urls.html 
*/ 
public function index() 
{ 
    $this->load->view('welcome_message'); 
} 

しかし、私はmysite.com、mysite.com/welcome、mysite.com/Welcomeに行くとmysite.com/Welcome.phpとき、私は毎回404を得る。

私のroutes.php:私はファイルを持っている

$route['default_controller'] = "home"; 
$route['404_override'] = ''; 
$route['translate_uri_dashes'] = FALSE; 

、Home.php:

<?php 

if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class Home extends CI_Controller { 

    public function __construct() { 
    parent::__construct(); 
    $this->load->model('general_model'); 
    } 

    public function index() { 
    $this->load->view("home/home_view"); 
    } 

    /* 
    public function coming(){ 
    $this->load->view("home/coming_soon_view"); 
    } 
    */ 
} 

私の.htaccessファイル:私は本当に見に苦労してる

RewriteEngine on 
    RewriteCond $1 !^(phpMyAdmin|index\.php|robots\.txt) 
    RewriteRule ^(.*)$ index.php?/$1 [L] 

<IfModule authz_core_module> 
    Require all denied 
</IfModule> 
<IfModule !authz_core_module> 
    Deny from all 
</IfModule> 

私が間違っていること。

+0

あなたは 'config ['index']' varには何を設定していますか? – Kisaragi

+0

config.phpから –

+0

はい、 '$ config ['index_page']' – Kisaragi

答えて

1

私は共有ホスティングでこの経験をしていますが、何とかインターネット上で見つけることができますが、誰がこの例を挙げているのか忘れているかもしれません。

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading 
    # slashes. 
    # If your page resides at 
    # http://www.example.com/mypage/test1 
    # then use 
    # RewriteBase /mypage/test1/ 
    RewriteBase/
    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. 
    # Submitted by: ElliotHaughin 

    ErrorDocument 404 /index.php 
</IfModule> 
1

あなたは

$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; 
$config['base_url'] = $protocol . $_SERVER['HTTP_HOST'] . str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']); 

にごBASE_URLを設定すると、これはあなたが後でそれを展開することができ、あなたの.htaccessファイルに必要なすべての

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

、単に最小限のセットアップを使用していますたった今。

+0

私はこれを試してみました。$ route ['default_controller'] = "welcome";しかし、$ route ['default_controller'] = "home"; –

+0

私は今設定していますが、tripmatcher.herokuapp.com/loginに行くときは、コントローラ内にlogin.phpがあるにもかかわらず、404が表示されます。 –

+0

URLにindex.phpを追加すると機能しますか? – qwertzman

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

これは私のために働いたものです。

関連する問題