Redirect Entire Domain with Flask

My blog used to be served from blog.amir.rachum.com. I recently decided to serve it from my “root” subdomain amir.rachum.com, but I wanted to keep all the old links working. This means that blog.amir.rachum.com should redirect to amir.rachum.com and that every URL should redirect to its appropriate counterpart under the new domain - blog.amir.rachum.com/x/y/z should point to amir.rachum.com/x/y/z.


This is a companion discussion topic for the original entry at http://amir.rachum.com/blog/2016/08/27/flask-redirect/

Why are you not using a .htaccess file for this? This would be even simpler and does not require to setup a new application.

See: http://stackoverflow.com/a/7578810/1211607