[web2py] Re: Subdomain based on blog users in routes.py
I love playing with subdomains and multiple domains, The * as dns entry is ok (be carefull with dns entries order), you can do it in routes.py, but I see more apropiate on models or controllers If you don't success, contact me and sure I'll solve it On Oct 5, 5:10 pm, Farsheed Ashouri farsheed.asho...@gmail.com wrote: ya, I am trying to solve it. Let's see what'll come up with this night! :)) Thank you Jonathan! On Wed, Oct 5, 2011 at 6:38 PM, Jonathan Lundell jlund...@pobox.com wrote: On Oct 5, 2011, at 8:03 AM, Farsheed Ashouri wrote: Well it worked!! but with many problems in Ajax loading! Thank you, but any improvements?? You might want to look at request.controller (and .function and .extension) to detect Ajax requests and do something else with them (depending on what the Ajax problems are). Otherwise all your Ajax requests coming from the subdomain will be sent to pages/blog, which is probably wrong. -- Sincerely, Farsheed Ashouri, ourway.ir Tel: +98 9388801504
[web2py] Re: Subdomain based on blog users in routes.py
ya, It works, but it's not was i expected. for example my own blog * rodmena.ourway.ir* http://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.
[web2py] Re: Subdomain based on blog users in routes.py
Yes Anthony, I've read it 50 times! but i cant figure out this one. your code doesn't work. I test it few times on my local and main server. :( I am giving up!
[web2py] Re: Subdomain based on blog users in routes.py
Does doing a simple redirect not work for you? if request.vars.u: redirect('%s.mysite.com' % request.vars.u)
[web2py] Re: Subdomain based on blog users in routes.py
So, Any reliable setting? Any alternative ways? probably with Apache settings?
[web2py] Re: Subdomain based on blog users in routes.py
Have you read through http://web2py.com/book/default/chapter/04#Pattern-Based-System? Not sure if this will work, but maybe something like: routes_in = (('http://$sub\.mysite\.com', '/myapp/pages/blog?user=$sub')) On Sunday, October 2, 2011 8:14:32 PM UTC-4, Farsheed Ashouri wrote: So, Any reliable setting? Any alternative ways? probably with Apache settings?
[web2py] Re: Subdomain based on blog users in routes.py
Any Idea? Please.
[web2py] Re: Subdomain based on blog users in routes.py
Have you looked in apache2/nginx redirect engine? On 2 окт, 05:23, Jonathan Lundell jlund...@pobox.com wrote: On Oct 1, 2011, at 3:13 PM, Jonathan Lundell wrote: On Oct 1, 2011, at 2:13 PM, Farsheed Ashouri wrote: I think i have no problem with DNS. cause i put a * value in subdomain setting of DNS and now i have access to any sub-domain i want. So you say there is no way to solve this in routes.py? With the regex mode, perhaps. On second thought, I *think* that the regex router doesn't give you access to the query string. So you might have to make the user part of the arg string (part of the URL path) in order for the router to work for you.