Mind that routes_in = [(...., 'code->url')] redirects to the url with code. 
It does not redirect on error. For there is a routes_onerror. It is 
documented in the routes.examples.py

On Thursday, 16 July 2015 16:47:52 UTC-5, ari wrote:
>
> Thank you very, very much. I've never thought that i can reroute an http 
> error. Again, Thank you!!
>
> joi, 16 iulie 2015, 03:00:31 UTC+3, Massimo Di Pierro a scris:
>>
>> Who says we do not have a clue? ;-)
>>
>> There are multiple ways:
>>
>> 1) The easiest way is to create a model file in your app that does:
>>
>>     redirect(URL(args=request.args, vars=request.vars, host='
>> your.new.host.com'))
>>
>> 2) It can be done at the routes level
>>
>> routes_in = [
>> ('/appname','301->http://your.new.host.com/appname/default/index'),
>> ('/appname/default','301->http://your.new.host.com/appname/default/index'
>> ),
>> ('/appname/default/index','301->
>> http://your.new.host.com/appname/default/index'),
>> #... more rules as needed
>> ]
>>
>> 3) (recommended) use iptables
>>
>> iptables -t nat -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
>> iptables -t filter -A FORWARD -d 1.1.1.1 -j ACCEPT
>>
>> 1.1.1.1 being the old server, and 2.2.2.2 being the new server.
>>
>> this will work even if the old server and the new server have the same 
>> DNS domain name!
>>
>> 3) is recommended because although web2py can do it, this is really not a 
>> job for web2py. This is a job for the OS.
>>
>>
>>
>>
>> On Wednesday, 15 July 2015 18:36:59 UTC-5, ari wrote:
>>>
>>> it is interesting that not even the poeple who created the routes, nor 
>>> the creator of web2py, doesn't have a clue how to redirect an app to 
>>> another server.
>>> maybe de logic behind the app is usefull?
>>>
>>> vineri, 10 iulie 2015, 02:32:28 UTC+3, ari a scris:
>>>
>>>> Hello!
>>>>
>>>> I have an web2py server with multiple apps. I want to redirect a 
>>>> specific app to a new server
>>>>
>>>> Example:
>>>> when i make the call
>>>> http://name_of_the_server/app_name/default/index
>>>>
>>>> it will be redirected to:
>>>> http://name_of_the_new_server/app_name/default/index
>>>>
>>>> i've tried the example from routes.example.py
>>>> into the best case scenario, when i have some response: was only adding 
>>>> into routes_in = ('BASE+/app_name/$anything'+
>>>> http://name_of_the_new_server/app_name/default/index)
>>>> but into the httpserver.log the entry is:
>>>> 10.8.52.24, 2015-07-09 18:33:19, GET, 
>>>> http://name_of_the_new_server/app_name/default/index, HTTP/1.1, 400, 
>>>> 0.000000
>>>>
>>>> the other cases was: only routes_out, both set.
>>>> Could you , please, help me with this. Thank you very much
>>>>
>>>>
>>>>

-- 
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 the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to