This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

moto0000
moto0000

How can I redirect to 404 page in my plugin ?!

Flynsarmy
Flynsarmy

404 in the backend when you go to one of your plugin URLs? This is intentional. You shouldn't be linking to any URLs that 404 in the backend. Try fixing your plugin instead.

EDIT: Misinterpreted what you were trying to do. My bad.

Last updated

Scott
Scott

Without more context of how and from where you're trying to redirect, this is the best answer I can give you.

function onRun() {
    return Redirect::to('/404');
}
moto0000
moto0000

Redirect to 404 page or call to NotFoundException in front-end, for example when Blog Post :slug doesn't exist.

Last updated

moto0000
moto0000

I use this code:

public function onRun()
{
    try
    {

        ...

    }
    catch(ModelNotFoundException $e)
    {
        $this->controller->setStatusCode(404);
        return $this->controller->run('/404');
    }

}

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.