How to pass multiple where in routes Laravel 5.4 -
i want pass 2 arguments in route working 1 only. below code.
route::group(['domain' => '{subdomain}'.'.example.com'], function() { // here goes subdomain handling // handle subdomain requests not found route::get('{slug}', function($subdomain, $slug) { return redirect(\url::to('http://example.com/'.$slug)); })->where('slug', 'admin')->where('slug', 'distributor'); }); for example:
www.ez.example.com/distributor redirecting www.example.com/distributor
but admin not working
it working distributor only. want work admin too,
the reason you're getting work 1 of where's because where's stored in array , keyed name pass (i.e. 'slug') 2nd 1 overrides 1st.
the where() method on route takes regular expression can is:
route::get('{slug}', function($subdomain, $slug) { return redirect(\url::to('http://example.com/'.$slug)); })->where('slug', 'admin|distributor'); hope helps!
Comments
Post a Comment