Well, after a few hours of testing with pattern-based routing system, I've achieved what I was looking for. Oh yeah :D Here is what I did, in case someone is trying to do the same (continuing the example of the first post).
In the web2py main folder, this is routes.py: routes_app = [ (r'.*?://recipes.com:\w* /$anything', r'recipes'), (r'.*?://traveler.com:\w* /$anything', r'traveler'), ] Notice that I will serve two apps per domain, but in the routes_app I specify only the main app. This allows me to define a routes.py for the main app of each domain. In my case, this is applications/recipes/routes.py: ('/', '/recipes/default/index'), ('/robots.txt', '/recipes/static/robots.txt'), ('/favicon.png', '/recipes/static/custom/favicon.png'), ('/download$anything', '/recipes/default/download$anything'), ('/static$anything', '/recipes/static$anything'), ('/panel/static$anything', '/recipes_panel/static$anything'), ('/panel', '/recipes_panel/default/index'), ('/panel$anything', '/recipes_panel$anything'), ] # for every function in the default controller for key in ('contact', 'other_function', 'aboutus', 'myfunction'): routes_in.append(('/%s$anything' % key, '/recipes/default/%s$anything' % key)) routes_in.append(('/$anything', '/recipes/default/index/$anything')) routes_out = [(x, y) for (y, x) in routes_in] Then I have applications/traveler/routes.py, which has the same content that the file before, but replacing "recipes" with "traveler". And that's it, works like a charm. *Now there is one thing that I couldn't achieve: how to avoid all the apps being accessed from any domain?* I'll close this question and post a new question about this. El sábado, 1 de abril de 2017, 10:52:54 (UTC-3), Lisandro escribió: > > Originally this was a question, but considering is something I need for my > business, I added "JOB POST" to the title. > If you consider that you know how to achieve what I need, I'm willing to > pay for the work. > Sorry if this is not the place to ask for a web2py developer (in that > case, the post is still a question to the group). > > > To help you understand, first let me tell *what I have right now*: > > - I have one web2py instance running. > - I developed two web2py apps that, together, they allow you to have > your website (like a blog) and manage it yourself: > - the first app is the public website, and right now it is > accessible through the top level domain: mywebsite.com > - one of the apps is the control panel, where you can post/edit new > articles, etc, and it is accessible through a subdomain: > panel.mywebsite.com > - I have several websites running, each one with its top level domain. > > I got all this working using *parameter-based* routing: > > routers = dict( > BASE=dict( > default_controller='default', > default_function='index', > domains={ > # one website > 'recipes.com': 'recipes', > 'panel.recipes.com': 'recipes_panel', > # another website > 'traveler.com': 'traveler', > 'panel.traveler.com': 'traveler_panel', > # ... several more websites ... > }, > root_static=['robots.txt'], > map_static=True, > exclusive_domain=True, > ) > ) > > *Note that with exclusive_domain=True, each app is accessible only through > one specific domain, and it's not possible to access it from another > domain.* > > However, consider this: what if I want to setup SSL for a website? > I would have to buy a wildcard SSL certificate, because I have the website > divided in two parts, one of them (the control panel) in a subdomain. > Wildcard SSL certificates are usually more expensive, and I don't want to > force that. > > > > > Considering all that, here is *what I want to achieve*: > > - Each website still would be formed by two web2py apps, so in our > example, we would still have these four web2py apps: > - applications/recipes > - applications/recipes_panel > - applications/traveler > - applications/traveler_panel > > - The public portion of a website would still have to be served in > the top level domain, and the default controller and default function > would > be 'default' and 'index' respectively, so: > - recipes.com/ ---------------> /recipes/default/index > - recipes.com/contact ----> /recipes/default/contact > - recipes.com/load/init ----> /recipes/load/init > - *(same stuff for every other domain)* > > - The control panel (and this is how it gets tricky) would have to > be served through /panel (notice that the app name is different), so: > - recipes.com/panel -------------------> > /recipes_panel/default/index > - recipes.com/panel/contenido ------> > /recipes_panel/default/contenido > - recipes.com/panel/ads/new --------> /recipes_panel/ads/new > > - traveler.com/panel -------------------> > /traveler_panel/default/index > - traveler.com/panel/contenido ------> > /traveler_panel/default/contenido > - traveler.com/panel/ads/new --------> /traveler_panel/ads/new > > - Each domain would allow to access only the couple of apps > regarding that website, that is: > - "recipes" and "recipes_panel" apps would only be accessible > trough recipes.com domain > - "traveler" and "traveler_panel" apps would only be accessible > trough traveler.com domain > > > > I think I need to use *pattern-based *routing system, but I've never used > python's regular expressions at all. I'm reading about it and doing some > tests, but I'm having a hard time to figure out how should I do it. > Remember that I'm willing to pay for the job if you consider that you know > how to do it. > > Thanks in advance! > Best regards, > Lisandro. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.