[web2py] routes question

46 views
Skip to first unread message

elffikk

unread,
Apr 25, 2010, 2:33:11 AM4/25/10
to web2py-users
hi,
I want to serve multiple websites (absolutely different domains) using
the same web2py instance

I am getting always an 'Invalid request' message

routes.py is something like that

routes_in = (
('^.*site1\.com.*/(.*)', '/site1/$1'),
('^.*site2\.com.*/(.*)', '/site2/$1'),
)

I read this post
http://groups.google.com/group/web2py/browse_thread/thread/4768cc04ad88c48d/ce9e4800f98591d2?lnk=gst&q=routes#ce9e4800f98591d2
and I thought that will work

Any thoughts?

mdipierro

unread,
Apr 25, 2010, 11:15:42 AM4/25/10
to web2py-users
This is described here
http://web2py.com/book/default/section/4/15
The full syntax is
[remote address]:[protocol]://[host]:[method] [path]
so you want something like this:

routes_in = (
('(.*):https?://(.*)site1\.com:(.*) /', '/site1/default/index'),
('(.*):https?://(.*)site2\.com:(.*) /', '/site2/default/index'),
)

On Apr 25, 1:33 am, elffikk <elff...@gmail.com> wrote:
> hi,
> I want to serve multiple websites (absolutely different domains) using
> the same web2py instance
>
> I am getting always an 'Invalid request' message
>
> routes.py is something like that
>
> routes_in = (
>   ('^.*site1\.com.*/(.*)', '/site1/$1'),
>   ('^.*site2\.com.*/(.*)', '/site2/$1'),
> )
>
> I read this posthttp://groups.google.com/group/web2py/browse_thread/thread/4768cc04ad...

Vasile Ermicioi

unread,
Apr 25, 2010, 11:51:39 AM4/25/10
to web...@googlegroups.com
worked, thank you!

need something like this

routes_in = (
  ('(.*):https?://(.*)site1\.com:(.*)/(.*)', '/site1/$4),
  ('(.*):https?://(.*)site2\.com:(.*)/(.*)', '/site2/$4'),
)

Jonathan Lundell

unread,
Apr 25, 2010, 12:12:07 PM4/25/10
to web...@googlegroups.com
At the very least, you might want something like this:

routes_in = (
('(.*):https?://(.*)site1\.com:(.*?)/(.*)', '/site1/$4'),
('(.*):https?://(.*)site2\.com:(.*?)/(.*)', '/site2/$4'),
)

...and you can use Massimo's nifty $anything pattern as well. Otherwise you'll translate something like this:

http://site1.com/a/c/f/a1/a2

into

/site1/a2

Have you tested your pattern with 'site1.com'? (That is, with no trailing slash?)




--
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
Reply all
Reply to author
Forward
0 new messages