On Feb 23, 2011, at 7:35 AM, Prashanth wrote:
> 
> Yes.. I got this working. I used wildcard CNAME record ( * )  and then
> used this code to redirect.
> if auth.user and auth.user.username != subdomain:
>    redirect('http://'+auth.user.username+'.'+get_request_path())

What exactly does get_request_path do? (That is, where is it getting the path?)

FWIW, this can support https dynamically thus:

    redirect('%s://' % request.env.get('WSGI_URL_SCHEME', 'http').lower(), ...

and in the latest stable release you can persuade URL() to do this for you.

Something like this (untested):

if auth.user and not request.env.http_host.startswith(auth.user.username + '.'):
    redirect(URL(r=request, host='%s.%s' % (auth.user.username, 
request.env.http_host)))

(Assuming, as in your code, that the user subdomain is simply prefixed and 
nothing needs to be stripped.)



> 
> Thanks for the support!
> 
> On Feb 23, 9:31 am, pbreit <pbreitenb...@gmail.com> wrote:
>> Did you ever get this working how you wanted? Did you stick to a wildcard
>> CNAME or A record? It seems to me that if you use an A record, the domain as
>> displayed in the address bar continues to include the sub-domain. Whereas a
>> CNAME does more of a redirect. Do I have that right?


Reply via email to