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.
toCode:example.com/view/unique-name
Code:example.com/unique-name
| SitePoint Sponsor |
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.
toCode:example.com/view/unique-name
Code: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.
"Folks who know what they're doing make complexity seem simple."
I use Laravel 4. If I set routes like so-
When user visitPHP Code:Route::get('{uniqueName}', function()
{
});
Route::get('category/{categoryName}', {
});
for Category Page, router will thinks "Code:example.com/category/category-name" is "category".Code:uniqueName
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.

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
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
Bookmarks