On Oct 5, 2011, at 7:36 AM, Farsheed Ashouri wrote:

> ya, It works, but it's not was i expected. for example my own blog 
> rodmena.ourway.ir now redirects to it's correct path, but i wanted to stay at 
> sub domain level while surfing.
> my code is simple:
> 
> #==== Blogs subdomain redirection =======
> host_parts = request.env.http_host.split('.')
> if len(host_parts) == 3:
>     subdomain   = host_parts[0]
>     main_domain = '%s.%s' % (host_parts[1], host_parts[2])
>     red_link    = '%s://%s/pages/blog?u=%s' % (request.env.wsgi_url_scheme, 
> main_domain, subdomain)
>     redirect(red_link)
> #========================================
> 
> Btw, thx all for their answer, but i still need to solve it in routes.

Try putting this in db.py (or your first model file, whatever it is). (This is 
strictly experimental, and I'm assuming that you have all your model files in 
the top level of the model directors.)

host_parts = request.env.http_host.split('.')
if len(host_parts) == 3:
    request.vars['u'] = host_parts[0]   # subdomain
    request.controller = 'pages'
    request.function = 'blog'
    response.view = '%s/%s.%s' % (request.controller,
                                  request.function,
                                  request.extension)



Reply via email to