Custom Routing for SEO friendly URLs |
I am having a routing problem that i don't understand , i'm following whats on the documentation, perhaps im not fully understanding how these routes work,
here is the issue, i have an articles Controller which makes use of view_by_slug method, this just grabs a field from the database that instead of having : http://localhost/kewlcms/articles/view/1 in the URLs i have this: http://localhost/kewlcms/articles/view_b...st-article http://localhost/kewlcms/articles/view_b...nd-article .. . This is the snippet i have on the home page that creates a list of the most recent posts, as you can see it uses view_by_slug/<?php echo $article->slug; ?> on home.php PHP Code: <ul class="row marketing"> But i would like to change these URLs: http://localhost/kewlcms/articles/view_b...st-article instead of articles/view_by_slug/first-article i would like to change it to : http://localhost/kewlcms/articles/first-article or http://localhost/kewlcms/blog/first-article This is what i have on routes.php, i am including the 2 lines which are the ones i tried so far but im getting 404 not found errors PHP Code: $route['articles/view_by_slug/(:any)'] = 'articles/$1' ;
Is kewlcms your controller, or your install dir?
Remove line $route['articles/view_by_slug/(:any)'] ='articles/$1':
Keep calm.
Did you try using _remap()? http://www.codeigniter.com/user_guide/ge...thod-calls
You can redirect every request to index() so that will serve another method. Website: http://avenir.ro
I think the problem is your URI http://localhost/kewlcms/articles/view_b...st-article. 'kewlcms' is always the first segment of your URI. Fire up your apps using PHP built-in webserver with option -t which is your document root, in your case, kewlcms directory.
Keep calm.
|
Welcome Guest, Not a member yet? Register Sign In |