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

Need to query database for new url redirect #61

Closed jrson83 closed 4 years ago

jrson83 commented 4 years ago

How can I redirect to a parameter if the parameter doesn't exist in the old URL? I need to redirect:

/labels/{name} to /label/{id}/{name}

I could use the name from the old URL to get the ID from the database inside a controller, but I don't understand Creating your own redirector chapter. Does this mean to create a controller?

Can you please give an example of a custom controller to select from the database?

SamuelNitsche commented 4 years ago

I think this could help you.

https://github.com/spatie/freek.dev/blob/master/app/Services/MissingPageRedirector/LegacyUrlsRedirector.php

jrson83 commented 4 years ago

Thanks, I gonna look into this. For now I created all redirects manually.