[英]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.