내가 CI 라우터 클래스가하는 일의 관점을 (이것은에서 이동에 나를 위해 가장 어려운 일이었다 "변경을 촉구한다 "라우터"접근법에 대한 재 작성 "접근법).
귀하의 질문은 "다시 쓰기"접근 방식을 가정하고 여기가 htaccess로 파일을 처리 할 수있는 방법은 다음과 같습니다
RewriteRule ^/download/(.*)$ index.php/download/?path=$1 [L]
이 방법에서, 당신은 단지 "/ 다운로드를 일치하도록 경로를해야합니다 "부분을 입력 한 다음 컨트롤러 동작에 $this->input->get('path')
을 사용합니다.
은 "라우팅"접근 방식은 동일 htaccess로 파일을 유지하고 $ 경로 설정뿐만 아니라 당신이 경우 컨트롤러가 그 정보를 "얻는다"방법과 같은 변경 :
<?php
// config/routes.php change:
$routes['download/(:any)'] = 'download/index/$1';
// controllers/download.php:
class Download extends CI_Controller {
public function index($folder, $file)
{
// if the folder is "flat" (i.e. no subfolders),
// you can simply use $folder and $file
var_dump($folder);
var_dump($file);
// otherwise, $file is the last segment ("n"),
// and folder is segments 2 through n
$segments = $this->uri->segment_array();
$folder = implode('/', array_slice($segments, 2, -1);
$file = end($segments);
// full path is always $folder and $file appended
$path = $folder.'/'.$file;
var_dump($path);
}
}
이가이다 접근 방식이므로 특정 요구 사항에 맞게 조정하십시오.
건배!
CodeIgniter는 쿼리 문자열 ([see docs (http://codeigniter.com/user_guide/general/urls.html))을 사용하지 않습니다. 이것을 위해 필요한 것을 설명해 주시겠습니까? – Grilse