spatie / laravel-missing-page-redirector

Redirect missing pages in your Laravel application
https://freek.dev/598-retain-your-seo-worth-by-correctly-redirecting-missing-pages-in-a-laravel-application
MIT License
488 stars 38 forks source link

Easier way to redirect URLs where only the first parameter is broken #56

Closed lasseeee closed 4 years ago

lasseeee commented 4 years ago

Would it be possible to do something like the following, instead of having to explicitly type out every nested URI from a site where only the first URI parameter has changed:

Psudocode:

'/centers/oldcentername1/(?*}' => '/centers/newcentername1/{?*}'
'/centers/oldcentername2/{?*}' => '/centers/newcentername2/{?*}'
'/centers/oldcentername3/{?*}' => '/centers/newcentername3/{?*}'

So in other words: Store whatever comes after the broken parameter (paths, parameters, query strings, etc.), and append it after the fixed parameter.

freekmurze commented 4 years ago

You can put whatever logic you want in a custom redirector: https://github.com/spatie/laravel-missing-page-redirector#creating-your-own-redirector