There is an example in the book related to redirection:
http://web2py.com/books/default/chapter/29/04/the-core?search=routes#Pattern-based-system
A less elegant way would be to: Using routes.py, map the /myc to the
path /app/controller/func. In the func(), redirect('url path to
company/myc'). This is, if you want to manage all of this in your app code.
nginx may have something for your case ... am not conversant enough in
that though.
________________________________________
Kiran Subbaraman
http://subbaraman.wordpress.com/about/
On Tue, 17-11-2015 4:20 AM, Sam Heather wrote:
Hi there,
I am trying to create redirects using web2py from effectively the
default index page (or just the route of the domain/package). Some
keywords (such as 'about', stored in a list) wouldn't redirect.
However, all not in that list would redirect.
The desired behaviour is:
|
https://startbean.com/about -> No redirect
https://startbean.com/myc -> https://startbean.com/company/myc
|
The default page that is shown at startbean.com is from the package
'default' and is called 'index'. If the redirect was as in the below,
it would be easy:
|
https://startbean.com/default/about -> No redirect
https://startbean.com/default/index/myc ->
https://startbean.com/default/company/myc
|
because the myc is a URL argument. But when it is from the root,
Web2Py tries to open a package called 'myc' and then finds no page
(index or controller function) so errors.
What is the best way of handling this? I was trying with routes.py,
but couldn't figure out a way to do this (am pretty sure it is not
supported). I thought about a redirect for the token after / to a page
called /default/redirect/<token> which would then decide about the
redirect, but there's no way to stop the infinite loop. Another
possible solution was a tweak to the nginx config so redirect when
there is one token after the /, but again I think this causes a
problem with the about.
Maybe there is a catch-all function for controllers that I haven't
found? I've gone through the web2py book and found nothing - any ideas
very welcome!
Thanks,
Sam
--
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]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
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.