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 37 forks source link

Feature - Pass HTTP status code on "RouteWasHit" event. #35

Closed gtapps closed 7 years ago

gtapps commented 7 years ago

Hello,

I needed to change the HTTP status code on a matched URL(from the "redirects" config array), even if the Redirect URL is empty. Basically, it allows us to set HTTP status code even if the redirect URL is empty. This is useful IMO since allows us to trigger 404, 410, or any other status code defined in the redirect even without a redirect URL.

Cheers, Gabriel

freekmurze commented 7 years ago

Could you add some tests to prove that these changes work? Could you also update the readme with an example of the new functionality?

gtapps commented 7 years ago

Hello Freek,

I noticed a small issue since I was using this implementation on a staging environment, so I had to tweak it. I added a test and added an example into the readme. Everything seems to work fine on my project.

Let me know what you think, Gabriel

freekmurze commented 7 years ago

That tweak adds a lot of complexity. It's also not clear to me what it does. Could you revert this PR to only add the status code to the event.

Propose all other changes in a separate PR.

gtapps commented 7 years ago

Sure Freek, I'm going to separate the things then.

Regarding the new feature, It just lets you override the http status code of a URL you have in the "redirects" array if it doesn't have a redirect URL. So I can trigger 410 and whatever status code I wish, based on a URL that is present there. If you check out the readme you can see what I mean.

Gabriel

freekmurze commented 7 years ago

Closing this for now.