samedi 29 décembre 2018

Symfony\Component\HttpKernel\Exception\NotFoundHttpException

I'm using laravel 5..7 and having some trouble on multilingual website... I have global route prefix for adding seo purposes. (adding lang parameters like en,tr to url)

 Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => in_array(Request::segment(1), $this->noLangPrefix) ? "" : Request::segment(1)
        ]...
i

t actually works pretty well with below Language middleware..

public function handle($request, Closure $next)
    {
        $langSegment = $request->segment(1);

        // go ahead if is admin panel or sitemap
        if ($langSegment == "admin")
            return $next($request);

        if ($langSegment == "sitemap.xml")
            return $next($request);

        // if is homepage 
        if (is_null($langSegment)) {
            app()->setLocale($request->getPreferredLanguage((config("app.locales"))));
            return $next($request);
        }

        if (strlen($langSegment) == 2)
            return $next($request);

        return redirect(url(config("app.locale") . "/" . implode($request->segments())));
    }

When i say, "app.test/blog" it redirects me to "app.test/tr/blog"

But if I say "app.test/blog/sample-blog-spot" it gives me Symfony\Component\HttpKernel\Exception\NotFoundHttpException

Why I'm getting this error ? Because it cant fine route or something and how can I fix it ?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2AnpDnA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire