Forums

How to redirect requests to PythonAnywhere?

I have a domain registered example.com hosting some blog stuffs, but there is a subdomain api.example.com(which hosts RESTful API) and I want all requests to that redirected to my app on PA. One way to do is to add CNAME record: api.example CNAME zerop.pythonanywhere.com

But I am not sure will this work? Or is there a better way to do what I want to do?

You'll need a Web Developer (i.e. paid) account in order to use your own domain with a PA app. That aside, using a CNAME record like you said will work just fine.

However, depending on the type of clients that will be using your API, you could get away with setting up an HTTP 301 redirect from api.example.com to your PA app (making sure to preserve the query string!) - browsers should follow the redirect, but other consumers may not!

Your domain registrar may have a facility to do this (often called web forwarding or subdomain forwarding).

Thanks, that helped.