mercredi 31 octobre 2018

Canonical Issue in Laravel with ID and Slug use

Looking for canonical issue in my site is I can get the right canonical url like

http://www.example.com/quotes/123/this_is_it

but if someone changes the 123 to 158 it still shows the content of 123. I think it get the content with the slug i.e. this_is_it.

What I want is to get a 404 or a redirect to actual page if someone tries to change any one of either {id} or {slug}

I got my route as

Route::get('/quotes/{id}/{slug}','QuotesController@quoteShow');

and controller as

public function quoteShow($id,$slug)
{
    $quotes= DB::table('quotes')->where('id', $id)->get();
    foreach ($quotes as $data) {
        $id= $data->id;
        $author_id= $data->author_id;
        $quote= $data->quote;
        $status= $data->status;            
    }

    $author= DB::table('authors_list')->where('id', $author_id)->get();
    return view('pages.quote',  ['author' => $author, 'quotes'=>$quotes]);
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire