Htaccess URL Rewrite: example.com/view/unique-name to example.com/unique-name

I am creating a blog with MVC Pattern. One blog post URL would be example.com/view/unique-name. But I want to rewrite that URL to following format.

example.com/view/unique-name

to

example.com/unique-name

I don’t think this is a job for htaccess rewrite rules. You’ll have to do this within your application’s router. And you’ll want to try this route last, since “unique-name” could be most anything and override your other site URLs.

I use Laravel 4. If I set routes like so-

Route::get('{uniqueName}', function()
{

});

Route::get('category/{categoryName}', {
	
});

When user visit

example.com/category/category-name

for Category Page, router will thinks "

uniqueName

" is “category”.
It will work if I set second Route in front of the first. But I have to set other routes for another custom pages.

Please help me.

You’ll have to put the “uniqueName” route last. It has to be the last route your application tries. Otherwise it could override any other route.

heinz,

It can be done … provided your CMS can accept the altered URI. Since I’m not aware of any that can, I’d recommend against it.

Regards,

DK