【发布时间】:2015-12-28 21:14:51
【问题描述】:
我正在使用 laravel 5.1,我想知道我是否只能在我的 routes.php 中允许特定的路由格式?
路由格式应如下所示(严格):
http://example.com/archive/2015-09
其中 2015-09 为年月。它应该只接受这种格式(如上所述)。具有不同的格式只会重定向到主页。示例:
http://example.com/archive/2015
http://example.com/archive/asd
http://example.com/archive/2015-9
http://example.com/archive/2
http://example.com/archive/2015-09-01
所以在我的路线中我有这个:
Route::get('archive/{date}', 'ArchiveController@index');
我在文档中看到了 regular expressions could be used,但我不确定我该怎么做。
【问题讨论】:
标签: php regex laravel laravel-4 laravel-5