mercredi 26 octobre 2016

Route for handling all requests except assets in Laravel

We are using Laravel 5 and have a route that handled all requests:

Route::any('{all}', 'AllController')
        ->where('all', '.*');

However this is causing one challenge: it redirects everything including images, JS and CSS.

We would like assets (static content) to be handled by the web server and Laravel to only handle dynamic content. We tried this:

Route::any('{all}', 'AllController')
        ->where('all', '.*')->where('all', !=, 'assets/.*');

But it gives syntax error unexpected '!=' (T_IS_NOT_EQUAL).

How can we construct a route that handles everything except assets (static content)?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire