I am trying to implement an array type route in Laravel 5.8.
Here's what I tried:
Route::get('/','/myroute', 'MyController@index');
Route::get(['/','/myroute'], 'MyController@index');
Route::get([('/','/myroute')], 'MyController@index');
Route::get('/' || '/myroute', 'MyController@index');
Basically, what I'm trying to do is to create a route with an "OR" condition.
Let's say I want to access MyController index
using mydomain.dev/
or mydomain.dev/myroute
but I am getting a 404|Not Found.
Tried to read the Laravel documentation but I can't find something that points me to what I'm trying to do.
Here is the example which you want to implement.
Route::get('/{param?}', 'MyController@index')
->where('param', '(myroute|myroute2)');
By above route you can create following urls for the same controller function
www.site.com/
www.site.com/myroute
www.site.com/myroute2
Try this I think this will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With