Welcome Guest, Not a member yet? Register   Sign In
URI Routing Like Wordpress Pages and Posts
#1

[eluser]cornofstarch[/eluser]
Hello,

I'm completely confused on how to do this correctly. I would like the routing to work similar to Wordpress routing.

For example, if you type in yoursite.com/about, it will go to the about page. But in this case, it would go to my "about" controller. I got as far as this:

routes.php
Code:
$route['^[0-9a-zA-Z][\w-]*[0-9a-zA-Z]$'] = "pages";

pages.php
Code:
class Pages extends Controller {

    function __construct() {
        parent::Controller();
    }

    function index() {
        $seg;
    
        if($this->uri->total_segments() == 1) {
            $seg = $this->uri->segment(1);
        }
        
        // check to see if the uri segment is a page in the database
        // if it matches and is in the database, redirect the visitor to that page
        
        redirect('login');
    }
}

But now when I want to redirect to my login controller, it breaks because it matches the condition in routes.php. I'm not sure how to proceed... can someone point me in the right direction on how to solve this?


Messages In This Thread
URI Routing Like Wordpress Pages and Posts - by El Forum - 01-21-2011, 02:01 AM
URI Routing Like Wordpress Pages and Posts - by El Forum - 01-21-2011, 03:57 AM
URI Routing Like Wordpress Pages and Posts - by El Forum - 01-21-2011, 05:24 AM
URI Routing Like Wordpress Pages and Posts - by El Forum - 01-21-2011, 12:13 PM
URI Routing Like Wordpress Pages and Posts - by El Forum - 01-21-2011, 10:57 PM
URI Routing Like Wordpress Pages and Posts - by El Forum - 01-22-2011, 06:31 PM
URI Routing Like Wordpress Pages and Posts - by El Forum - 01-24-2011, 02:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB