【发布时间】:2015-05-21 06:38:36
【问题描述】:
我正在尝试使用一组别名创建一个路由,所以当我在 url 中调用 whois 或 who_is 时,它会转到相同的路由。
那我就不用每次都重复代码了,只改别名就行了。
我尝试了下面的代码。
路径中的变量:
$path = 'App\Modules\Content\Controllers\ContentController@';
$aliases['whois'] = '(quemsomos|who_is|whois)';
路线:
Route::get('{whois}', array('as' =>'whois', 'uses' => $path.'getWhois'))->where('whois', $aliases['whois']);
这个也可以
Route::get('{whois}', $path.'getWhois')->where('whois', $aliases['whois']);
输入网址my_laravel.com/whois 或my_laravel.com/who_is 或my_laravel.com/quemsomos 会将我发送到$path.'getWhois' (正确)。
但是当我尝试在刀片上的 html 中调用它时...
<a href="{{ route('whois') }}">Who we are</a>
参考链接转到my_laravel.com//%7Bwhois%7D
如何在我的blade.php 上调用route('whois') 并让它像我在url 上键入时一样工作?
我想在我的刀片中使用route 函数,这样我就可以保留一个模式。
【问题讨论】:
标签: php laravel laravel-4 blade laravel-routing