dimanche 31 décembre 2017

Laravel redirect to correct path on missing routes

in my application when user enter this url as http://ift.tt/2Ch8cbl laravel show error as an

Sorry, the page you are looking for could not be found.

for that correct path is http://ift.tt/2zSIVOF and i'm trying to manage that and adding missing segment for that for example:

Route:

Route::get('{lang?}/showContent/aboutUs', array('as' => 'lang', 'uses' => 'HomeController@showAboutUsPage'))->where('lang', '.+');

mapping routes:

protected function mapWebRoutes()
{
    $locale = request()->segment(1);
    if ($locale != 'fa' && $locale != 'en') {
        $locale = 'fa';
    }
    app()->setLocale($locale);


    Route::middleware('web')
        ->namespace($this->namespace)
        ->prefix($locale)
        ->group(base_path('routes/web.php'));
}

on mapWebRoutes function i'm using multi language and manage routes, and for missing parameters as language key on segment(1) i get error, now how can i add missing segment or manage routes to redirect to correct path?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire