megacolorboy

Back

Published on March 12th, 2021

Laravel

How to exclude certain slugs in Laravel

Using plain Regular Expressions, you can exclude certain slug from your routes, try adding the following to your file:Hope you found this useful!

1 minute read

Using plain Regular Expressions, you can exclude certain slug from your routes, try adding the following to your routes/web.php file:


<php
    Route::match(array('GET', 'POST'), '/{slug}', 'YourController@index')->name('page')->where('slug', '^(?!pattern).*$');
?>

Hope you found this useful!