我是laravel的新手,我正在尝试将所有传入请求从/example
重定向到exampleController@index
,我正在使用此路由
Route::match(['get', 'post'], '/example/{any}', ['uses' =>'exampleController@index'])->where('any', '.*');
/example/any/any/any
一切都很好,但当我尝试/example/any/any/any.php
时,我遇到了No input file specified.
错误。请帮助我解决这个问题。谢谢
Route::match
仅用于将多个HTTP Verbs
与一条路由匹配。
据我所知,你无法实现你想要的,这样做毫无意义。
您可能需要的是Route::resource
检查文档
通过编辑NGINX配置文件使其工作。在我的情况下,我使用默认配置的laravel 5家园。配置文件位于/etc/nginx/sites-enabled/homestead.app
。在location ~ '.php$
之后添加try_files $uri $uri/ /index.php?$args;
。应该看起来像这个
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
}