Forums

How to point my domain to pythonanywhere without www prefix

Hi there,

I have already created a CNAME record to point www on my domain to my python application. However I would also like to point the domain itself (with no www prefix) to it. Is that possible? I admit I'm not too familiar with DNS settings. It used to point to a site hosted somewhere else, but I'm moving it here.

Thanks!

Creating a CNAME for a "naked" domain like that isn't permitted in the RFCs - see this question and answer for some discussion and a quote from the relevant standard.

If your DNS provider offers any kind of HTTP-level redirection then you could use this to send a permanent redirect from the naked version to the www version. This essentially entails them setting the A record for your naked domain to the IP address of a webserver they host, and have this server send nothing but redirects. I'm not sure if all DNS hosts provide this, however. Here's an example for setting it up on GoDaddy.

+1 to what Cartroo says. A catch-all redirect (so that when people go to http://yourdomain.com/something they are redirected to http://www.yourdomain.com/something) is definitely the best solution, for two reasons:

  • You can only point the "naked" yourdomain.com domain to a fixed IP address. This makes it harder for us to load-balance your site by by moving it from machine to machine.
  • If you have two sites with the same content, yourdomain.com and www.yourdomain.com, then when people link to you they can use either one. This means that you could wind up with 50% of your incoming links going to the naked domain, and 50% to the www one. This in turn means that half of the pagerank Google-juice will wind up associated with one version of the site, and half with the other -- so you'll wind up further down the search results than you would if it was all concentrated on one of them. (I've also heard, but can't confirm, that because Google try to spot sites that just duplicate other ones for spamming purposes, having your site apparently available in two places can reduce the pagerank even further, so you wind up with less than half the pagerank you would otherwise get)

If you'd like us to help with setting up a redirect, drop us a line here on the forums or privately via the "Send feedback" link letting us know who your registrar is and we'll see if we can find out how to do it.

I contacted my registrar (pairNIC) and was able to set up the redirection as suggested.

Just to clarify, those issues above are both resolved because the redirection occurs on their webserver and from the view of pythonanywhere, everything is coming from www.yourdomain.com. Is that correct?

Thanks for your help!

Yup, from the point of view of PythonAnywhere (and Google) your content will all be served from www.yourdomain.com

Can anyone help me with this? My website www.eabsentee.org works well, but eabsentee.org does not. I'm using NameCheap. I've tried adding a redirect but it's not working. Here is my redirect: https://ibb.co/SKKkHm7

That's not working because your web app is at https://www.eabsentee.org. Both of those redirects are going to a site that does not exist. If you make that redirects go to https://www.eabsentee.org, then it should work.