dimanche 6 décembre 2015

Handle url's character casing in Laravel?

How to I redirect following urls to lower case url?

http://ift.tt/1NbDpXf

http://ift.tt/21GBcgg

http://ift.tt/1NbDpXh

to

http://ift.tt/21GB9RK

This is my route:

Route::any('/{city}/{slug}/{page?}', 
    array(
        'as' => 'slug-page', 
        function($city, $slug, $page="info"){
        return View::make('default.template.'.$page)
            ->with('city', $city)
            ->with('page',$page)
            ->with('slug', $slug);
        }
    ))
    ->where(
        array(
            'city'   => '[a-z ]+',
            'page'   => '[a-z-]+',
            'slug'  => '(about|photos|videos)'
    ));

Currently I used regex [a-z-]+ to match only smaller case strings and that throws NotFoundHttpException for obvious reasons. How do I accept all these parameters in case insensitive strings and 301 redirect(to avoid duplicate urls) to smaller case urls in Laravel 5.1?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire