web2py, virtual domains and routes.py

96 views
Skip to first unread message

Mauro Allegrini

unread,
Feb 10, 2014, 9:51:21 AM2/10/14
to web...@googlegroups.com
Hi all
I'm trying to use virtual domains and a single web2py instance with multiple apps, 
My host is pythonanywhere.com. They have been kind but unable to help me on this and suggested me to ask here.

I've created PA domains, I've set up CNAME in my DNS and copied wsgi file to make them all the same (as required by PythonAnywhere FAQ)
So far so good.

The only part which is not working is the web2py routes.py:

Here is the relevant part:
-------------------------------------------
routers = dict(

     # base router
     BASE=dict(
         default_application='ivrdemoclient',
         default_controller='script1',
         default_function='index',
         domains = {
             "www.domain1.it":"parkmi",
             "www.domain1.com":"parkmi",
             }
     ),
     parkmi = dict(
                default_controller='default',
         default_function='index',
         )
)

------------------------

Basically, I have a default app (without a formal domain, for now) and two other domains www.domain1.it and www.domain1.com which should be routed to parkmi web2py app
Instead when I open www.domain1.it  the default app (and default controller and function) show up as if domains key is ignored

I've double checked DNS so that is not an issue. 

Can anybody help me?

Thank you in advance guys
Mauro

Jonathan Lundell

unread,
Feb 10, 2014, 10:13:02 AM2/10/14
to web2py
As usual, restart your server after making routes.py changes.

Then make sure that HTTP_HOST in request.wsgi.environ matches the domain name in your domains dictionary.

A minor point, and not relevant to your problem: I'd write the routers this way, so that app-specific defaults (in this case 'script1') are contained in app routers.

routers = dict(

# base router
BASE=dict(
default_application='ivrdemoclient',
domains = {
"www.domain1.it":"parkmi",
"www.domain1.com":"parkmi",
}
),
ivrdemoclient = dict(
default_controller='script1',
)
parkmi = dict()
)
Reply all
Reply to author
Forward
0 new messages