This project is read-only.

Apache htaccess

     In order to use the N2F Router, you must first setup the .htaccess in the N2F parent directory. The .htaccess file will redirect all non existent file and directory structures to the starting index.php page.

    <IfModule mod_rewrite.c>
        Options -Indexes
        RewriteEngine On

        RewriteCond %{DOCUMENT_ROOT}/$1/$2 -f [OR]
        RewriteCond %{DOCUMENT_ROOT}/$1/$2 -d
        RewriteRule (.*) - [S=2]

        RewriteRule ^(.*)resources/(.*)$ resources/$2 [L]
        RewriteRule ^([^/]+)\/(.*)$ index.php?_n2froute=$1/$2 [L]

     You can see that the bottom RewriteRule is placing the entire structure into a parameter called _n2froute. The N2F Router will then break apart all the sections of the _n2froute and place them into the request parameters.

Creating a New Route

     You can simply create a new route by adding a single line:


         n2f_router::create('news', array(
              'year' => date('Y'),
              'month' => date('m')


     This will create a new route for the 'news' module, which will take the parameters year, and month, with the defaults being the current year, and month. Now when you visit:

     it will load the 'news' module, and set the year and month within the global $_REQUEST variable, so that it looks like this:

     $_REQUEST['nmod'] = 'news';
     $_REQUEST['year'] = '2000';
     $_REQUEST['month'] = 06;

Last edited Nov 11, 2012 at 2:41 AM by cbutcher84, version 2


No comments yet.