On Jan 10, 2012, at 7:14 AM, Carlos wrote:

> My environment: latest web2py, ubuntu, postgresql, nginx, uwsgi.
> 
> I need to handle multiple subdomains:
> 
>    http:// sub.domain.com / args ? vars
> 
> All of them must internally point to the following url structure:
> 
>    http:// www.domain.com / app / controller / function / sub / args ? vars
> 
> The whole url path (domain, app, controller, function) will be exactly the 
> same in all subdomain cases, but each subdomain must be passed as the first 
> arg (plus all the other args and vars), and it must handle incoming and 
> outgoing urls.
> 
> Examples:
> 
>    from:  http:// test.domain.com /
>    to:  http:// www.domain.com / app / controller / function / test
> 
>    from:  http:// demo.domain.com / arg1 / arg2 ? var1=1 & var2=2
>    to:  http:// www.domain.com / app / controller / function / demo / arg1 / 
> arg2 ? var1=1 & var2=2
> 
> Should this be somehow solved with web2py's parameter or pattern based 
> routes?.
> 

The parametric router won't do this for you directly. You could, though, use 
the parametric router and put something like this at the beginning of db.py: 
extract the subdomain from request.env.get('HTTP_HOST') and insert it as 
element 0 of request.args.

web2py's outgoing URLs don't ordinarily include the domain, unless you 
explicitly pass it (or a scheme) to URL() as an argument. 

WAYRTTD?

Reply via email to