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');
        }
    }
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3eCxJMj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire