In my application when user enter this url as http://127.0.0.1:8000/showContent/aboutUs
laravel show error as an
Sorry, the page you are looking for could not be found.
for that correct path is http://127.0.0.1:8000/en/showContent/aboutUs
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?
sorry for duplicate comment! it is related to your web server. you can use .htaccess file for that. another way is to use exception handler. you can check the exception type and also the request route. then redirect to appropriate url if it is necessary.
My problem solved:
i change
kernel.php
to :and
Language
class to: