Need help rewriting url so that "http://mydomain.com/myapp" looks like "http://myapp.mydomain.com/"

55 views
Skip to first unread message

Lisandro

unread,
Mar 12, 2014, 3:19:31 PM3/12/14
to web...@googlegroups.com
I'm using web2py on production with lighttpd. My site has two web2py applications: "init" and "guide". I already created routes.py to hide "init" from the url. 
In addition, I would like that "guide" application appears as a subdomain, so that every url of this form "mydomain.com/guide/" looks like "guide.mydomain.com"

For example, this url
should look like

I don't mind using lighttpd mod_rewrite or web2py routes.py... But I don't have **any** experience in regular expresions. So I was wondering if someone could give me a hand on this, maybe sharing some examples of similar cases.

Thanks in advance! Regards, Lisandro.

Dan Feeney

unread,
Mar 13, 2014, 1:09:48 PM3/13/14
to web...@googlegroups.com
You shouldn't need regex for this. Try using the domains key instead of default_application in routes.py:

routers = dict(
  BASE  
= dict(
    domains
= {'guide.mydomain.com': 'guide',
                    
'mydomain.com': 'init',
             
}
  )
)



hth

Lisandro Rostagno

unread,
Mar 13, 2014, 3:45:24 PM3/13/14
to web...@googlegroups.com
Thank you very much. So simple and clean solution. 
One more question: ¿is there any way to test this in localhost with web2py development server? 


--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/EhuNoc0TJto/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages