Routing Codeigniter

2

I am making a site with administrative area using the Framework Codeigniter. In the administrative area, the user can create new pages for the site. The content of the page will be saved to the database.

The controller that reads the pages of the database is called: page

So when pages are created, they are currently accessed like this:

  • www.site.com.br/ page / page1
  • www.site.com.br/ page / page2

My question: Can you delete the word "page" from the URL using the URI Routing?

    
asked by anonymous 10.11.2014 / 17:01

2 answers

1

The best way for a dynamic routing is to use the database, and to have the file routes read the table.

This link demonstrates how CodeIgniter can be done.

    
19.11.2014 / 06:42
1

Routes works more or less like this. any request that exists after the domain, for example www.site.com.br/ page it treats as controller.

That is, if you want to delete the word " page " it would look something like this.

$routes["pagina1"] = "page/pagina1";

In $ routes [" pagina1 "] you replace with the word you would like to call, and in "page / page1" you put the path, page would be the controller and pagina1 function.

so any request instead of typing "www.site.com.br/page/page1" would look like this: "www.site.com.br/page1"

    
11.11.2014 / 14:03