Is is possible to redirect base url '/' to a mounted application at /xyz via config

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is is possible to redirect base url '/' to a mounted application at /xyz via config

ARN NN
Hi,

If I have an app mounted at say : '/xyz'
I want that when users invoke url '/' via browser, I want it to redirect to '/xyz'

Is this possible via config  ?
I tried doing it by adding a config section to my app :

[/] 
tools.redirect.on = true
tools.redirect.url = "/xyz"

but this didn't work. Any idea whats wrong and how to fix ?

thanks in advance
n.ar.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/d782f418-759b-48dc-967e-91703f284e2c%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Is is possible to redirect base url '/' to a mounted application at /xyz via config

Michiel Overtoom
Hi,

> On 2020-04-15, at 21:22, ARN NN <[hidden email]> wrote:
>
> Is this possible via config?

I tried your example, but it led to a redirect loop.

I had success with the following code:


#!/usr/bin/env python3

import cherrypy

class Website:
    @cherrypy.expose
    def index(self):
        raise cherrypy.HTTPRedirect("/xyz")

    @cherrypy.expose
    def xyz(self):
        return "Hello from xyz"

if __name__ == "__main__":
    cherrypy.quickstart(Website(), "/")



--
"You can't actually make computers run faster, you can only make them do less." - RiderOfGiraffes

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/928A3BD8-45A6-4797-8A4C-109423D21DA7%40xs4all.nl.
Reply | Threaded
Open this post in threaded view
|

Re: Is is possible to redirect base url '/' to a mounted application at /xyz via config

Björn Pedersen
In reply to this post by ARN NN
Best solution for a production instance is to use a suitable frontend  proxy server (e.g. nginx or apache) to handle such things.

Björn

Am Mittwoch, 15. April 2020 21:22:47 UTC+2 schrieb ARN NN:
Hi,

If I have an app mounted at say : '/xyz'
I want that when users invoke url '/' via browser, I want it to redirect to '/xyz'

Is this possible via config  ?
I tried doing it by adding a config section to my app :

[/] 
tools.redirect.on = true
tools.redirect.url = "/xyz"

but this didn't work. Any idea whats wrong and how to fix ?

thanks in advance
<a href="http://n.ar" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fn.ar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH_0H-vIDJZgqvvEauXsPKfUrVdsg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fn.ar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH_0H-vIDJZgqvvEauXsPKfUrVdsg&#39;;return true;">n.ar.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/47e31077-5dc8-4929-b61f-d9b678ae750f%40googlegroups.com.