2014-10-23 5 views
0

나는 웹 기반 CodeIgniter의를 만들려고 해요,하지만 내 웹 사이트, 나는 온라인

이 내 htaccess로 파일을 넣을 때이 문제를 발견

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

그리고 이것은 내 설정이다 :

$config['uri_protocol'] = 'PATH_INFO'; 

그리고이 내 R outes.php

$default_controller = "Front"; 
$controller_exceptions = array('owner'); 

$route['default_controller'] = $default_controller; 
$route["^((?!\b".implode('\b|\b', $controller_exceptions)."\b).*)$"] = $default_controller.'/$1'; 
$route['404_override'] = ''; 

그리고 이것은 내 컨트롤러 클래스 :

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
class Front extends CI_Controller { 

    public function __construct() 
    { 
     parent::__construct(); 
    } 

    public function _remap($segment_1) 
    {  
    $segment_1 = $this->uri->segment(1); 
    switch ($segment_1) 
    { 
     case null: 
     case false: 
     case '': 
     $this->load->library('Facebook_ion_auth'); 
     if (isset($_GET['code'])) 
      { 
      $this->facebook_ion_auth->login(); 
      if (!$this->ion_auth->logged_in()){ 
       $this->index(); 
      }else{ 
       $succses='Selamat datang! <b>'.$this->ion_auth->user()->row()->user_display_name.'</b>'; 
       $content = new Content(); 
       $content->profil($succses,''); 
      } 
     }else{ 

      $url = $this->uri->segment_array(); 
      print_r($url); 
     } 

     break; 

     case 'category': 
      $this->category(); 
     break; 

     case 'search': 
      $content = new Content(); 
      $content->search(); 
     break; 

     case 'pesan': 
      $content = new Content(); 
      $content->pesan(); 
     break; 

     case 'daftar': 
      $content = new Content(); 
      $content->daftar(); 
     break; 

     case 'login': 
      $content = new Content(); 
      $content->login(); 
     break; 

     case 'keluar': 
      $content = new Content(); 
      $content->keluar(); 
     break; 

     case 'profil': 
      $content = new Content(); 
      $content->profil(); 
     break; 

     case 'kirimpesan': 
      $content = new Content(); 
      $content->kirimpesan(); 
     break; 

     case 'contact': 
      $content = new Content(); 
      $content->contact(); 
     break; 

     case 'testimoni': 
      $content = new Content(); 
      $content->testimoni(); 
     break; 

     case 'facebook': 
      $this->load->library('Facebook_ion_auth'); 
      $this->facebook_ion_auth->login(); 
     break; 

     case 'img': 
      $this->img(); 
     break; 

     default: 
     $content = new Content(); 
     $content->sigle(); 
     break; 
     } 
    }                          

    public function index() 
    { 
     $content = new Content(); 
     $content->home(); 
    } 
} 

그러나 항상이 증명 것을 경우 = ""를 실행하는 $ segment_1 = $ this- > uri-> segment (1);을 (를) 찾을 수 없습니다. 또는 URI (1)에서 데이터가

$url = $this->uri->segment_array(); 
print_r($url); 

표시합니다 , 고정 URL을 주문하는 방법 를 검출 할 수 EMPTY 표시하지. 또는 URL에서 매개 변수를 가져 옵니까 ??

답변

0
당신이 을하고 싶지만 당신이 당신의 URI

를 제공하는 경우가 좋은 것입니다 무엇을 이해하지 못하는

이 있습니다 : // 사이트/또는 : // 사이트/전면 ?? 이미 _remap 함수에서 매개 변수로

주를 보내 때문에

이 라인

$segment_1 = $this->uri->segment(1); 

를 제거하는 경우이 같은 클래스 이름과 기능없이 URL : // 사이트/ 세그먼트가 URL에 존재하지 않기 때문에

$this->uri->segment(1) 

의지는 거짓과 동일

+0

Codeigniter URL 클래스에 대한 설명서도 확인하십시오. https://ellislab.com/codeigniter/user-guide/libraries/uri.html – Mhisham

+0

: // site/== site/Front /이 코드를 다시 작성하십시오. 주셔서 감사합니다. , 나는 방금 튜토리얼을 여기에서 시도했다 -> http://www.web-and-development.com/codeigniter-remove-index-php-minimize-url/, localhost에서 작동하지만 온라인 상태 일 때는 작동하지 않는다. –

+0

Ok try 이것이 효과가 있는지 없는지 $ this-> uri-> rsegment (1); – Mhisham