I'm not sure if it will work, but you might try something like this in
routes.py:
routes_in = (
(r'.*?://(?P<sub>[^.]*).*?/app/web/site/(?P<any>.*)',
r'/app/web/site/\g<sub>/\g<any>')
)
Note, that uses the pattern-based rewrite system, which cannot be mixed
with the parameter-based rewrite system, so make sure your routes.py does
not contain a "routers" dictionary (which will take precedence over any
routes_in/routes_out).
I suppose you'll also need a routes_out. It probably just needs to remove
the subdomain arg from the URL:
routes_out = (
(r'/app/web/site/(?P<sub>.*?)/(?P<any>.*)', r'/app/web/site/\g<any>')
)
Anthony
On Monday, March 12, 2012 3:42:49 PM UTC-4, Carlos wrote:
>
> Hi,
>
> My previous related post:
> https://groups.google.com/d/topic/web2py/TxACULvgxik/discussion
>
> Following is my url path structure to access websites for multiple
> Organizations (ORG)
>
> http:// domain.com / app / web / site / ORG / args ? vars
>
> I can successfully access the website for DEMO ORG as:
>
> http:// domain.com / app / web / site / DEMO / args ? vars
>
> And I am using the following BASE routes dict:
>
> default_application = 'app'
> default_controller = 'web'
> default_function = 'site'
>
> So I can now use short urls:
>
> http:// domain.com / site / DEMO / args ? vars
>
> But now I require to access it via subdomain (removing 'site' function and
> ORG first arg, but being able to keep using args and vars):
>
> http:// DEMO.domain.com / args ? vars
>
> Internally rewriting to: http:// domain.com / app / web / site / DEMO /
> args ? vars
>
> Is there any way I can accomplish this with routes?.
>
> Thanks,
>
> Carlos
>
>