3

이 질문을 많이 보았지만 문제를 해결할 수 없었습니다.codeigniter 페이지 매김에서 404 오류

색인 페이지를 제거하기 위해 리라 우트 구성 및 htaccess가 있으므로 올바른 세그먼트를 읽지 않을 것으로 예상됩니다.

코드가 404 페이지를 던지고 있습니다.

public function get_city_reviews($city_id,$limit,$offset) { 

    $list = array(); 

    $this->db->from('biz'); 

    $this->db->where('city_id',$city_id); 

    $this->db->order_by('created_at','desc'); 

    $this->db->limit($limit,$offset); 

    $query = $this->db->get(); 
    foreach($query->result() as $row) { 

    $list[] = $row; 

     } 

    return $list; 

    } 

내 컨트롤러 :

  $slug = $this->uri->segment(1,''); 
    if($slug) 
    { 
     $this->load->model('catsAndCities','cc'); 
     $this->cc->set_table_name('city'); 
     $city = $this->cc->get($slug,'slug'); 

     if(!$city || $city->parent_id != 0) 
     { 
      show_404(); 
     } 
     else 
     { 
      $this->tank_auth->set_user_city($city); 
     } 
    } 
    else 
    { 
     $city = $this->tank_auth->get_user_city(); 
    } 
    $this->load->library('pagination'); 

    $config = array(); 

    $base_url ="local/index/"; 

    $config["base_url"] = site_url().$base_url; 

    $config["total_rows"] = $this->bizs->record_count(); 

    $config["per_page"] = 5; 

    $config["uri_segment"] = 4; 

    $config['full_tag_open'] = '<p class="pageBar">'; 

    $config['full_tag_close'] = '</p>'; 

    $config['num_links'] =2; 

    $config['anchor_class'] = 'class="page-num" '; 

    $this->pagination->initialize($config); 

    $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0; 

    $data["results"] = $this->bizs->get_city_reviews($city->id,$config["per_page"], 
    $page); 

    $data["pagination_links"] = $this->pagination->create_links(); 

    $data['reviews'] = $data["results"]; 

    $this->load->view('local/index',$data); 

내보기 :

<div id="pagination-container"> 
<div class="pagination"> 
    <ul> 

     <?=$pagination_links?> 

    </ul> 
    </div> 
이 내 경로 :

여기

내 모델입니다
$route['default_controller'] = "local/city"; 
    $route['[0-9a-zA-Z\-_]+'] = "local/city"; 
    $route['scaffolding_trigger'] = ""; 

이내 htaccess로이다 :

<IfModule mod_rewrite.c> 
RewriteEngine On 

#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] 

#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> 


ErrorDocument 404 /index.php 
</IfModule> 

답변

1

로 변경 도시가 없으면 404 페이지. 이 문제를 언급 해보십시오. 또는 해결 방법을 찾으십시오.

 if(!$city || $city->parent_id != 0) 
    { 
     show_404(); 
    } 
    else 
    { 
     $this->tank_auth->set_user_city($city); 
    } 

그런 다음

$base_url ="local/index/"; 

$config["uri_segment"] = 1; 

1

$base_url =""; 

그리고 세그먼트

에 그것을해야 그 변경합니다.

+0

나는 오는 사람이 잘 작동한다는 것을 보지 못했다. –

0

이 "지역/도시"를 BASE_URL를 변경 시도하고 uri_segment 내가 의심, 당신이 찾을 CI를 말하고있다 3.

+0

@Winterrain 그게 전부입니다. 404 페이지. –

+0

실제로 어떤 URL이 404를 던집니까? 기본 페이지 1이 작동하는지 또는 페이지 2,3 등으로 만 404가 표시되는지 여부. – Winterain

+0

첫 페이지가 작동하지만 원하는 제한을 얻었지만 나머지는 404를 던졌습니다. –