Answered here: http://stackoverflow.com/a/33830342/440323

Anthony

On Friday, November 20, 2015 at 1:52:05 AM UTC-5, Sam Heather wrote:
>
> Thanks for the reply Kiran - I have gone through that section of the book 
> a couple of times and can't find an answer to what I want.
>
> I should clarify: 'myc' is a generic token - a URL argument - I should 
> have written it as <token> or <arg>.
>
> The full path of the application is /default/company/myc, where 'default' 
> is the package, company is the function, and 'myc' is a URL argument. Is it 
> possible to do this with routes.py without adding a new entry to the 
> routes,py file for every instance of the redirect (an ever changing list, 
> thousands of entries, requiring lots of reloading of the routes.py!).
>
> Does what I am trying to do make a bit more sense now?
>
> Thanks!
>
> Sam
>
> On Tuesday, November 17, 2015 at 9:24:29 AM UTC+1, Kiran Subbaraman wrote:
>>
>> 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 Subbaramanhttp://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].
>> 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.

Reply via email to