views:

337

answers:

2

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.

+2  A: 

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.

Nick Johnson
Ok, a suspected that it can't be done. Thanks.
vartec
A: 

GAE requires you to specify only one domain name for a particular application. You can specify as many subdomains as you like (www1.example.com, www2.example.com, etc), but you cannot map any domains beyond example.com to it.

It is not a direct answer, but depending on the host names you are looking to manage, what you want to do may not be possible.

Nathan Voxland
For example there is generic appid.appspot.com name, I'd like to have that redirected to www.example.com.
vartec