What's the proper way to force a redirect from www.example.com to example.com in Flask? Normally you would do this Apache or Nginx, but when you host on Heroku, you have to do it in Flask. - James -- Bulbflow: A Python framework for graph databases (http://bulbflow.com)
Honestly, I'd recommend doing this at a DNS level, but you can also do it with request_started or middleware. -- Kenneth Reitz On Saturday, March 31, 2012 at 4:24 PM, James Thornton wrote: > What's the proper way to force a redirect from www.example.com (http://www.example.com) to > example.com (http://example.com) in Flask? > > Normally you would do this Apache or Nginx, but when you host on > Heroku, you have to do it in Flask. > > - James > > -- > Bulbflow: A Python framework for graph databases (http://bulbflow.com) > >
+1 > Honestly, I'd recommend doing this at a DNS level, but you can also do > it with request_started or middleware. > > -- > Kenneth Reitz > > On Saturday, March 31, 2012 at 4:24 PM, James Thornton wrote: > >> What's the proper way to force a redirect from www.example.com >> <http://www.example.com> to >> example.com <http://example.com> in Flask? >> >> Normally you would do this Apache or Nginx, but when you host on >> Heroku, you have to do it in Flask. >> >> - James >> >> -- >> Bulbflow: A Python framework for graph databases (http://bulbflow.com) > -- "Talk is cheap, show me the code" -- Linus Torvalds Regards Kracekumar.R www.kracekumar.com
How would you do this on the DNS level? I usually see this as a 301 redirect via the app. On Mar 31, 2012, at 4:28 PM, Kenneth Reitz <me@kennethreitz.com> wrote: Honestly, I'd recommend doing this at a DNS level, but you can also do it with request_started or middleware. -- Kenneth Reitz On Saturday, March 31, 2012 at 4:24 PM, James Thornton wrote: What's the proper way to force a redirect from www.example.com to example.com in Flask? Normally you would do this Apache or Nginx, but when you host on Heroku, you have to do it in Flask. - James -- Bulbflow: A Python framework for graph databases (http://bulbflow.com)
Most good DNS providers have something similar to a URL record or a redirect system built in for this. -- Kenneth Reitz On Saturday, March 31, 2012 at 4:31 PM, Philip Cammarata wrote: > How would you do this on the DNS level? I usually see this as a 301 redirect via the app. > > On Mar 31, 2012, at 4:28 PM, Kenneth Reitz <me@kennethreitz.com (mailto:me@kennethreitz.com)> wrote: > > > Honestly, I'd recommend doing this at a DNS level, but you can also do it with request_started or middleware. > > > > -- > > Kenneth Reitz > > > > > > On Saturday, March 31, 2012 at 4:24 PM, James Thornton wrote: > > > > > What's the proper way to force a redirect from www.example.com (http://www.example.com) to > > > example.com (http://example.com) in Flask? > > > > > > Normally you would do this Apache or Nginx, but when you host on > > > Heroku, you have to do it in Flask. > > > > > > - James > > > > > > -- > > > Bulbflow: A Python framework for graph databases (http://bulbflow.com) > > > > > > > > > > > > >
namecheap.com for example does this but it accomplishes it by sending an HTTP redirect. It's transparent because the user only receives the HTTP headers. On Sat, Mar 31, 2012 at 4:37 PM, Kenneth Reitz <me@kennethreitz.com> wrote: > Most good DNS providers have something similar to a URL record or a > redirect system built in for this. > > -- > Kenneth Reitz > > On Saturday, March 31, 2012 at 4:31 PM, Philip Cammarata wrote: > > How would you do this on the DNS level? I usually see this as a 301 > redirect via the app. > > On Mar 31, 2012, at 4:28 PM, Kenneth Reitz <me@kennethreitz.com> wrote: > > Honestly, I'd recommend doing this at a DNS level, but you can also do it > with request_started or middleware. > > -- > Kenneth Reitz > > On Saturday, March 31, 2012 at 4:24 PM, James Thornton wrote: > > What's the proper way to force a redirect from www.example.com to > example.com in Flask? > > Normally you would do this Apache or Nginx, but when you host on > Heroku, you have to do it in Flask. > > - James > > -- > Bulbflow: A Python framework for graph databases (http://bulbflow.com) > > > >
Well, You can use CNAME record(www.example.com) to point to example.com. > How would you do this on the DNS level? I usually see this as a 301 > redirect via the app. > > On Mar 31, 2012, at 4:28 PM, Kenneth Reitz <me@kennethreitz.com > <mailto:me@kennethreitz.com>> wrote: > >> Honestly, I'd recommend doing this at a DNS level, but you can also >> do it with request_started or middleware. >> >> -- >> Kenneth Reitz >> >> On Saturday, March 31, 2012 at 4:24 PM, James Thornton wrote: >> >>> What's the proper way to force a redirect from www.example.com >>> <http://www.example.com> to >>> example.com <http://example.com> in Flask? >>> >>> Normally you would do this Apache or Nginx, but when you host on >>> Heroku, you have to do it in Flask. >>> >>> - James >>> >>> -- >>> Bulbflow: A Python framework for graph databases (http://bulbflow.com) >> -- "Talk is cheap, show me the code" -- Linus Torvalds Regards Kracekumar.R www.kracekumar.com
How about using meta-tag redirect ? So have an html page as redirect.html, define redirect as <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.sub.yourdomain.com/index.html"> > What's the proper way to force a redirect from www.example.com to > example.com in Flask? > > Normally you would do this Apache or Nginx, but when you host on > Heroku, you have to do it in Flask. > > - James > -- "Talk is cheap, show me the code" -- Linus Torvalds Regards Kracekumar.R www.kracekumar.com
http://flask.pocoo.org/docs/api/#flask.redirect
http://en.wikipedia.org/wiki/HTTP_301 for a "*Moved Permanently* "
def index():
return redirect('http://example.com/index.html', code=301)
Or something along those lines.
On Sat, Mar 31, 2012 at 4:29 PM, kracethekingmaker <
kracethekingmaker@gmail.com> wrote:
> How about using meta-tag redirect ?
>
> So have an html page as redirect.html, define redirect as <meta
> HTTP-EQUIV="REFRESH" content="0; url=
> http://www.sub.yourdomain.com/index.html">
>
>
> What's the proper way to force a redirect from www.example.com
toexample.com in Flask?
>
> Normally you would do this Apache or Nginx, but when you host on
> Heroku, you have to do it in Flask.
>
> - James
>
>
>
>
> --
> "Talk is cheap, show me the code" -- Linus Torvalds
> Regards
> Kracekumar.Rwww.kracekumar.com
>
>