Routing Codeigniter

Asked

Viewed 166 times

2

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

The controller that reads the database pages is called: page

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

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

My question: You can delete the word "page" from the URL using the Routing URI?

2 answers

1


The best way to a dynamic routing is by using the database and, make the file routes read the table.

This link demonstrates how it can be done in Codeigniter.

  • Thank you. That’s what I’ve been looking for.

1

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

that is, if you want to suppress the word "page" would be more or less that.

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

in $Routes["pagina1"] you substitute for the word you would like to call, and in "page/page1" you put the path, page would be the controller and pagina1 the function.

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

  • And you could do it dynamically?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.