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

Andreea@Webclix's avatar

Laravel Slugs on hosting.

Hello.

I just pushed a website onto shared hosting and apparently the slugs broke completely. At first, the page wouldn't even load, showing an error while Page::findBySlug would return null.

    public function index($slug)
    {
        $page = Page::findBySlug($slug);
        $pageTemplate = $page->templates->first();
        return view('frontend.pages.index', compact('page','pageTemplate'));
    }

Now it actually loads the page but shows the custom 500 error for front page and 404 where it pulls the slugs from db. If I dd($page) it still returns null.

EDIT: I pulled the same version of the app but with it being already installed (instead of rolling with composer instal) from the testing platform and it simply works so I doubt it has anything to do with the hosting. I'd still appreciate an answer given that I'd like to do it the correct way. Is there anything I should setup slugs-wise after running a fresh install?

What am I missing here? Thanks.

0 likes
1 reply

Please or to participate in this conversation.