I am new to laravel, and im trying to get redirect all incoming requests from /example
to exampleController@index
I am using this route
Route::match(['get', 'post'], '/example/{any}', ['uses' =>'exampleController@index'])->where('any', '.*');
Everything works fine with /example/any/any/any
, but I am getting No input file specified.
error when i try /example/any/any/any.php
Please help me to solve this problem. Thanks.
Route::match
is only used to match multiple HTTP Verbs
to a route.
As far as I know you can't achieve what you want, and there is no point to do this.
What you may need is Route::resource
check the docs
Managed to get it working by editing NGINX config file. In my situation im using laravel 5 homestead with default configuration. Config file is located /etc/nginx/sites-enabled/homestead.app
. Add try_files $uri $uri/ /index.php?$args;
right after location ~ \\.php$
. Should look similar to this
location ~ \.php$ {
try_files $uri $uri/ /index.php?$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
....
}
I am not sure as to why, but you can use Route::group with a prefix as such
Route::group(['prefix' => 'example'], function() {
Route::get('action/{id}', 'ExampleController@getAction');
});
Going to http://yoursite.com/example/action/111 will use the getAction method in the ExampleController.
public function getAction($id) {
// do something with Example with this $id
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.