这是我正在访问的网址:http://example.com/hotel/expired
而是去这条路线的好控制器
Route::get('/hotel/expired', ModuleLoader::load_controller(_ACCOUNT , 'redirectExpired'));
这是使用的路线:
Route::post('/hotel/search', 'HotelControllerB2C@search');
但是,如果我更改此/hotel/session/expire 的/hotel/expire 路由,将使用正确的控制器
Route::any('/hotel/search/{dep_date}/{dep_code}/{ret_date}/{ages}', 'HotelControllerB2C@showSearch');
Route::any('/hotel/search/{dep_date}/{dep_code}/{ret_date}/{ages}/{property_type}', 'HotelControllerB2C@showSearch');
Route::post('/hotel/search', 'HotelControllerB2C@search');
Route::get('/hotel/detail/{index}', 'HotelControllerB2C@showDetail');
Route::post('/hotel/detail', 'HotelControllerB2C@detail');
Route::get('/hotel/{sid}', ModuleLoader::load_controller(_ACCOUNT , 'showPreviousSearch'));
Route::any('/hotel/confirmation/{url}', ModuleLoader::load_controller(_ACCOUNT , 'confirmation'));
Route::get('/hotel/expired', ModuleLoader::load_controller(_ACCOUNT , 'redirectExpired'));
为什么拉拉维尔认为/hotel/expire 是/hotel/search ? 一个使用发布方法,另一个使用获取...
幼虫中的路由按照您定义的顺序解析。在那之后,你有/hotel/{sid}
和/hotel/expired
,所以在这种情况下:
/hotel/anything => goes to /hotel/{sid} route
/hotel/expired => also goes to /hotel/{sid} route
为了避免这种情况,您应该首先定义最具体的路由,然后定义更通用的路由,因此在您的情况下,您应该放置 line:
Route::get('/hotel/expired', ModuleLoader::load_controller(_ACCOUNT , 'redirectExpired'));
以前
Route::get('/hotel/{sid}', ModuleLoader::load_controller(_ACCOUNT , 'showPreviousSearch'));