I have been using a route wildcard for my root path (/) successfully until I decided to move my frontend files behind a prefix (/crm). After that I am getting 404's and have no idea how to solve it. I need the wildcard as a catch all for my Javascript frontend routes (/crm/orders/details/12345) which otherwise result in a 404.
So when I remove prefix('crm') everything as set up with the below code works fine. Or when I remove {any} plus the matching regex, it works partially, on one level deep routes (/crm works, but /crm/orders does not).
But when I have both the prefix and wildcard /crm gives me a 404.
How do I need to configure this?
Works
Providers/RouteServiceProvider.php:
Route::namespace('App\Http\Controllers')
->group(base_path('routes/crm.php'));
routes/crm.php
Route::get('/{any}', function ()
{
return view('crm');
})->where('any', '.*');
Does not work
Providers/RouteServiceProvider.php:
Route::prefix('crm')
->namespace('App\Http\Controllers')
->group(base_path('routes/crm.php'));
routes/crm.php
Route::get('/{any}', function ()
{
return view('crm');
})->where('any', '.*');
Output of php artisan route:list is as follows
| Domain | Method | URI |Name | Action | Middleware |
*snap*
| | GET|HEAD | crm/{any} | | Closure | |
*snap*