ixudra
3 years ago

Preserving old slugs

Posted 3 years ago by ixudra

Hi all

I'm converting an old app to Laravel 5. This old app uses slugs to direct the user to certain pages. Sadly, these slugs need to remain functional because of SEO purposes. I'm trying to recreate these slugs in my routes but am unable to do so. Below is my code

Route::pattern('id', '[0-9]+');
Route::pattern('old-slug', '[a-zA-Z\_\-()]+');


Route::group(array(), function()
{
    Route::get(     '',                array('as' => 'index',          'uses' => 'HomeController@index'));
    Route::get(     '{old-slug}',      array('as' => 'slug',           'uses' => 'HomeController@slug'));
});

Some slugs are the following:

http://myapp.dev/University_of_Nebraska
http://myapp.dev/University_of_Nevada
http://myapp.dev/UNM
http://myapp.dev/UNC

Any thoughts on how I can fix this?

Please sign in or create an account to participate in this conversation.