2014-05-21 2 views
0

저는 Laravel 4를 사용하고 있습니다. URL이 다음과 같이 보이는 cms 페이지를 만들려고합니다 : domain.tld/en/how-it-works. 그들은 백 오피스를 사용하여 생성되며 슬러그 how-it-works과 현재 언어를 사용하여 가져옵니다. 문제는 내가 정적 페이지 인 domain.tld/login에 액세스하려는 경우 해당 페이지가 데이터베이스에서 발견되지 않았기 때문에 404 페이지를 표시한다는 것입니다. 그래서 주어진 슬러그를 찾을 수없는 경우 다른 경로를 찾는 솔루션을 찾고 있어요.라우팅 다시 매핑 Laravel 4

도와주세요.

영어로 죄송합니다.

$languages = array('fr', 'en'); 
$locale = Request::segment(1); 
if(in_array($locale, $languages)){ 
\App::setLocale($locale); 
}else{ 
$locale = null; 
} 

Route::group(array('prefix' => $locale), function() 
{ 


    Route::get('/', array('before' => 'loginCookie', 'uses' => '[email protected]', 'as' => '/')); 

Route::get('{slug}',array('uses' => '[email protected]', 'as' => 'articles.show')); 

    Route::group(array('prefix' => 'login'), function() { 
     Route::get('/', array('before' => 'guest', 'after' => 'reflashPool', 'uses' => '[email protected]')); 
     Route::post('/',array('before' => 'guest|csrf','after' => 'reflashPool', 'uses' => '[email protected]')); 
     Route::get('remind-password',array('uses' => '[email protected]')); 
     Route::post('remind-password','[email protected]'); 
     Route::get('reset-password/{token}','[email protected]'); 
     Route::post('reset-password','[email protected]'); 
    }); 
+0

:

그래서, 당신은 당신의 가장 일반적인 경로 마지막을해야? – Laurence

+0

방금 ​​추가했습니다 :) –

답변

1

가 가능한 한 빨리이 내 routes.php 파일은, 당신이 그들을 쓰기 순서와 요구 사항을 충족 처음에 Laravel 프로세스 경로는 choses 하나입니다. 당신의 경로는 파일을 게시

Route::group(array('prefix' => $locale), function() 
{ 

    Route::get('/', array('before' => 'loginCookie', 'uses' => '[email protected]', 'as' => '/')); 

    Route::group(array('prefix' => 'login'), function() { 
     Route::get('/', array('before' => 'guest', 'after' => 'reflashPool', 'uses' => '[email protected]')); 
     Route::post('/',array('before' => 'guest|csrf','after' => 'reflashPool', 'uses' => '[email protected]')); 
     Route::get('remind-password',array('uses' => '[email protected]')); 
     Route::post('remind-password','[email protected]ostRemind'); 
     Route::get('reset-password/{token}','[email protected]'); 
     Route::post('reset-password','[email protected]'); 
    }); 

    Route::get('{slug}',array('uses' => '[email protected]', 'as' => 'articles.show')); 

}); 
+0

오 고마워, 그 작품 :) –

+0

두 테이블 (두 컨트롤러)를 사용한다고 가정하고, 첫 번째 오류가 발생하면 어떻게 두 번째 테이블을 검색 할 수 있습니까? ? –