How to shorten URL name for web2py with multiple controllers

41 views
Skip to first unread message

Warwick JC

unread,
Aug 6, 2020, 1:46:43 PM8/6/20
to web2py-users
Hello.
I only note that this works only for the index page.

routers = dict(
# base router
    BASE
=dict(
        default_application
='init',
   
),
   
# app specific router
    rivelar
=dict(
        default_controller
='default',
        default_function
='index'
   
)


)

I would also like to shorten the names for other pages as well, especially if you have multiple controllers. How can I dpo this?
Regards

villas

unread,
Aug 10, 2020, 12:47:23 PM8/10/20
to web2py-users
I'm pretty sure that you could omit the default_controller from all your routes, if you wish.  Obviously additional controllers should be explicit.

To shorten names,  I suggest you set up aliases to your normal functions.  You can do this on your webserver,  or using the web2py routes file,  or you can even redirect at the beginning of a controller for example.

Also, take a look at the notes in the file:  routes.parametric.example.py  (in the dir:  web2py/examples)

My own experience tells me to make urls meaningful rather than short (especially for SEO),  but of course this may not apply in your case.

Reply all
Reply to author
Forward
0 new messages