Welcome Guest, Not a member yet? Register   Sign In
Hard Routes Problem
#3

[eluser]Gonzo2[/eluser]
Sorry! I realize that you don't want controller and method in the URL just the route with page name. So you need to work like this:

eg: First put all your controllers into regular expression EXCEPT which you do not want to route and let others get routed to your pages/page/page_name.

$route['^(?!admin|members).*'] = "pages/page/$0";

Here I am not allowing admin and members to route, you can change them as per your requirements.

Now in your pages controller and page method capture the uri segment[0].

i.e:
class Pages extends CI_Controller
{
function index()
{
$page_name = $this->uri->segment(0);
}

function page($page_name)
{
$this->load->view($page_name);
}
}


Hope this is what you are looking for and load the url helper if it is not autoload.

Gonzo


Messages In This Thread
Hard Routes Problem - by El Forum - 03-18-2011, 08:41 AM
Hard Routes Problem - by El Forum - 03-18-2011, 11:01 AM
Hard Routes Problem - by El Forum - 03-19-2011, 05:15 PM
Hard Routes Problem - by El Forum - 03-21-2011, 04:52 AM
Hard Routes Problem - by El Forum - 03-22-2011, 03:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB