using (:num), (:any) in routing for SEO

Submitted by doguhan - 10 years ago

Laravel de URL desenlerini yazılımcının sabit bir yaklaşımından uzaklaştırarak SEO için renklendirmeye yarayan bazı kullanımları.. http://elmacademy.net/

//for laravel 5
<?php

 // app/http/routes.php
 //exam:1
Route::get('discussion/(:num)-(:any)/edit', array('uses' => 'discussion@edit'));
//exam:2
Route::get('discussion/(:num)-(:any)/(edit|delete)', 'discussion@(:3)');
// (:3) meaning get edit or delete

//exam:3
Route::get('user/(:any)/userid/(:num)', function($user, $useridnumber)
 {
 // $username will be replaced by the value of (:any)
 // $useridnumber will be replaced by the integer in place of (:num)

 $data = array(
 'username' => $username,
 'userid' => $useridnumber
 );

 return View::make('edit.user', $data);
 });
 
 //exam:04
 Route::get('api/(v1|v2)/(:any)/(:any).(json|xml)', 'api.(:1).(:2)@(:3)');