lundi 3 mars 2014

Hide all controller and function names from the URLs web2py


Vote count:

0




Similar question, which didn't solve my problem.


I want my app to have unique string identifiers (slugs) for every page, and to make URLs shorter I'm trying to hide the controller and function names from the URL. So, instead of this:



app/c/f/some-slug


I'd like to get this:



app/some-slug


If I just set "c" as default controller and "f" as default function and try to visit app/some-slug (given that "f" can handle such slug), web2py gives an "invalid controller (my)" error.


Since I couldn't get the pattern-based URL rewriting to work (maybe because I just did it wrong), I think I would need to store each slug along with its default controller and function names in the DB and some kind of "universally default" function to handle all this. Then, if I needed to do another action to some page, I'd put the action name in front of the slug in the URL.


So... Is it feasible? Exaggerated? A terrible idea?



asked 3 mins ago






Aucun commentaire:

Enregistrer un commentaire