Is it possible to define static rule for 301 redirect to canonical host name? I.e. I’d like what in Apache’s mod_rewrite is done with:
# To force the use of RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*) http://www.example.com/$1 [L,R=301]
I know I can do that in Python code, but I’d prefer to keep that separated.
No, it’s not possible to do that purely in app.yaml. You can, however, define an extremely simple request handler in Python, and then use that to perform rewrites. The handler can be separate from the one you use for the rest of your app, so you’re still maintaining a degree of separation.