CodeIgniter Forums

Full Version: how to rewrite/remap/route ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]ka-spot[/eluser]
I'm building CMS and I have different controllers for Users, Pages, Products, Categories, etc.

Database table with urls for products and pages.

And I want this:

example.com/some-page -> check db table -> execute controller pages
example.com/some-product -> check db table -> execute controller products
example.com/login -> check db table -> execute controller login
example.com/вход -> check db table -> execute controller login
example.com/register -> check db table -> execute login/register
and so on..


How to do it ?

El Forum

[eluser]Phil Sturgeon[/eluser]
Use $route['404_override'] and send it to a "pages" controller, which has a public function _remap();

Inside that remap put your database logic and find a page, or output a 404 page.

El Forum

[eluser]ka-spot[/eluser]
[quote author="Phil Sturgeon" date="1340543908"]Use $route['404_override'] and send it to a "pages" controller, which has a public function _remap();

Inside that remap put your database logic and find a page, or output a 404 page.[/quote]


I still dont understand how to execute login/register (users controller with his own methods) from "pages" controller (different controller)?

El Forum

[eluser]Phil Sturgeon[/eluser]
You are looking at it the wrong way. You are thinking:

1. Send everything to pages except...
2. Send only users login and logout to their method

Wrong.

1. Send specific custom routes as normal.
2. Allow CI to route controllers and methods as it always does
3. Use the 404_override to send everything else to the pages controller.

El Forum

[eluser]ka-spot[/eluser]
Get it.