mardi 27 avril 2021

Return 404 in Laravel RouteServiceProvider

I want to give a 404 response if index.php is found in the url. example url is domain.com/index.php/about

expected : return blade 404

I've tried this code but can't get the 404 display

class RouteServiceProvider extends ServiceProvider
{
    protected $namespace = 'App\Http\Controllers';

    public function boot()
    {
        parent::boot();
    }

    public function map()
    {
        $this->removeIndexPhpFromUrl();
    }

    protected function removeIndexPhpFromUrl()
    {
        $currentUrl = url()->current();
        if(strpos($currentUrl, 'index.php') !== false){
            return view('errors.404');
        }
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire