Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

emco83's avatar

Redirect page not found (404) to the homepage

I've recently finished developing a new Laravel website and now it's online. Unfortunately Google shows old links from the previous website. I know that's because of the indexing, so it takes time.

When I click on some old link, it shows page not found. Not so nice for the visitors.

Is there any easy method on Laravel to set redirect to the homepage when someone visits a page that doesn't exist? I don't need any authentication login, only simple redirect to the '/' page.

0 likes
3 replies
emco83's avatar

Btw, I've sorted out by creating the 404.blade.php in views/errors folder and set inside redirect function with Javacript.

I'm just curious is it possible to do this with Laravel?

emco83's avatar
emco83
OP
Best Answer
Level 1

@rob897 I've already checked that link, but that is only for creating custom 404 page (I've already did that), it's not a simple redirect to the homepage.

Well, I guess I'll stick with the JavaScript approach.

Please or to participate in this conversation.