[英]Laravel 5 Routing ALL routes
我是laravel的新手,我试图将所有来自/example
传入请求重定向到exampleController exampleController@index
我正在使用这条路由
Route::match(['get', 'post'], '/example/{any}', ['uses' =>'exampleController@index'])->where('any', '.*');
使用/example/any/any/any
一切正常,但是我收到了No input file specified.
我尝试/example/any/any/any.php
时出错请帮我解决这个问题。 谢谢。
Route::match
仅用于将多个HTTP Verbs
与路由匹配。
据我所知,你无法达到你想要的效果,没有必要这样做。
您可能需要的是Route::resource
检查文档
通过编辑NGINX配置文件来管理它。 在我的情况下我使用laravel 5宅基地默认配置。 配置文件位于/etc/nginx/sites-enabled/homestead.app
。 添加try_files $uri $uri/ /index.php?$args;
在location ~ \\.php$
之后location ~ \\.php$
。 应该看起来与此类似
location ~ \.php$ {
try_files $uri $uri/ /index.php?$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
....
}
我不确定为什么,但你可以使用带有前缀的Route :: group
Route::group(['prefix' => 'example'], function() {
Route::get('action/{id}', 'ExampleController@getAction');
});
转到http://yoursite.com/example/action/111将使用ExampleController中的getAction方法。
public function getAction($id) {
// do something with Example with this $id
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.