당신은 당신의 경로와 창조적 일 필요 것 : http://ellislab.com/codeigniter/user-guide/general/routing.html
당신은 모든 트래픽을 잡아하고 listing
방법 다음 directory/listing
로 가리 키도록 경로를 설정할 수 있습니다 - 당신은 수동으로 URL 세그먼트에 액세스 할 수 있습니다 . 예를 들어 : 아마의 경우와 같이
// application/config/routes.php
$route[':any'] = "directory/listing";
/**
you might have to play with this a bit,
I'm not sure, but you might need to do something like:
$route[':any'] = "directory/listing";
$route[':any/:any'] = "directory/listing";
$route[':any/:any/:any'] = "directory/listing";
$route[':any/:any/:any/:any'] = "directory/listing";
*/
// application/controllers/directory.php
function listing()
{
// docs: http://ellislab.com/codeigniter/user-guide/libraries/uri.html
$state = $this->uri->segment(1);
$city = $this->uri->segment(2);
$unique_id = $this->uri->segment(3);
$unique_page_name = $this->uri->segment(4);
// then use these as needed
}
은 또는, 당신은 다른 컨트롤러와 메소드를 호출 할 수 있어야합니다 - 컨트롤러를 가리 키도록 당신은 URL을 변경할 수 있습니다
을 다음 목록의 물건을 할
asdf.com/directory/{state}/{city}/{unique_id}/{unique-page-name}/
및 경로가 될 것입니다 : -
그래서 귀하의 URL이 될 것
$route['directory/:any'] = "directory/listing";
그런 다음 listing
방법의 URI 세그먼트를 업데이트하여 2, 3, 4 및 5 번째 세그먼트를 일치시켜야합니다.
이 방법, 당신은 여전히 다른 컨트롤러를 호출 할 수 있고 그것은 사용자 정의 경로에 의해 체포되지 않을 것이다 :
asdf.com/contact/ --> would still access the contact controller and index method
UPDATE
또한 창의력과에 정규 표현식을 사용할 수 있습니다 첫 번째 URI 세그먼트에있는 주 이름이있는 URL을 찾으십시오. 그런 다음 URL을 directory/listing
으로 보내면 다른 모든 컨트롤러가 계속 작동하므로 URL에 directory
컨트롤러를 추가 할 필요가 없습니다. 이 같은 것이 작동 할 수도 있습니다 :
// application/config/routes.php
$route['REGEX-OF-STATE-NAMES'] = "directory/listing";
$route['REGEX-OF-STATE-NAMES/:any'] = "directory/listing"; // if needed
$route['REGEX-OF-STATE-NAMES/:any/:any'] = "directory/listing"; // if needed
$route['REGEX-OF-STATE-NAMES/:any/:any/:any'] = "directory/listing"; // if needed
/**
REGEX-OF-STATE-NAMES -- here's one of state abbreviations:
http://regexlib.com/REDetails.aspx?regexp_id=471
*/
경로에 대해 알아 보려면 해결 방법이 있습니다. 사용자 안내서 –