-1
나는 laravel을 배우기 시작했다. 그리고 nettuts + (url shortner)의 작은 샘플 프로젝트를 발견했습니다. 그것은 잘 작동하지만 내가 직면하는 문제는 (: any) 라우트가 작동하지 않는다는 것입니다. 여기 제가 파일에있는 세 가지 경로가 있습니다.laravel 3 - (: any) route not working
Route::get('/', function()
{
return View::make('home.index');
});
Route::post('/', function()
{
$url = Input::get('url');
// Validate the url
$v = Url::validate(array('url' => $url));
if ($v !== true) {
return Redirect::to('/')->with_errors($v->errors);
}
// If the url is already in the table, return it
$record = Url::where_url($url)->first();
if ($record) {
return View::make('home.result')
->with('shortened', $record->shortened);
}
// Otherwise, add a new row, and return the shortened url
$row = Url::create(array(
'url' => $url,
'shortened' => Url::get_unique_short_url()
));
// Create a results view, and present the short url to the user
if ($row) {
return View::make('home.result')->with('shortened', $row->shortened);
}
});
Route::get('(:any)', function($shortened)
{
// query the DB for the row with that short url
$row = Url::where_shortened($shortened)->first();
// if not found, redirect to home page
if (is_null($row)) return Redirect::to('/');
// Otherwise, fetch the URL, and redirect.
return Redirect::to($row->url);
});
첫 번째 두 경로는 정상적으로 작동하지만 세 번째 경로는 작동하지 않습니다. URL에서 index.php로 호출하면 작동합니다. /index.php/abc와 비슷하지만/abc에서도 작동해야합니다. 그리고 fyi, 나는 응용 프로그램 설정 파일에서도 index.php 설정을 제거했습니다.
해결할 수 있습니까?