2016-08-01 131 views
1

我是新来laravel和IM试图让所有的请求重定向从/example[email protected]我使用这条路线Laravel 5路由的所有路由

Route::match(['get', 'post'], '/example/{any}', ['uses' =>'[email protected]'])->where('any', '.*'); 

一切工作正常与/example/any/any/any,但我正在逐渐No input file specified.错误当我尝试/example/any/any/any.php请帮我解决这个问题。谢谢。

+1

NGIX将转发请求到.php文件到PHP文件处理程序,而不检查文件是否存在。在Apache中,这通常使用mod_rewrite解决我猜NGIX有类似的东西。检查http://nginxlibrary.com/resolving-no-input-file-specified-error/ – apokryfos

+0

嗨,感谢您的评论,我设法通过更改我的NGINX配置来做我想要的。简单地添加这个'try_files $ uri $ uri//index.php?$ args;'现在它按预期工作。 –

+0

如果您使用解决方案回答自己的问题,它可能会帮助其他人。 – apokryfos

回答

0

Route::match仅用于将多个HTTP Verbs匹配到路由。

据我所知,你不能达到你想要的,没有必要这样做。

你可能需要的是通过编辑NGINX配置文件Route::resource检查文档

0

设法得到它的工作。在我的情况下,我使用默认配置的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; 
     .... 
    } 
0

我不知道是为什么,但是你可以使用路由::组前缀这样

Route::group(['prefix' => 'example'], function() { 
    Route::get('action/{id}', '[email protected]'); 
}); 

http://yoursite.com/example/action/111将使用的getAction方法中ExampleController。

public function getAction($id) { 
    // do something with Example with this $id 
} 
+0

我正在研究“智能”代理服务器,所以我希望所有传入的请求到'application.com/proxy/{method}/{method}?{parameters}'将使用相同的方法'ProxyController @ index'。任何方式..扩展问题修复,感谢您的意见。干杯 –