Report this

What is the reason for this report?

Add www to my url

Posted on October 14, 2017

How can I add www to my URL?

I followed the instructions for setting a host name here, but whenever I browse for http://www.foo.com, I get redirected to http://foo.com.

How do constantly keep www.foo.com?

I have the following DNS records:

Type Hostname Value TTL (seconds)
CNAME *.foo.com is an alias of www.foo.com. 43200
A foo.com directs to 201.227.660.894 3600
A www.foo.com directs to 201.227.660.894 3600
NS foo.com directs to ns1.digitalocean.com. 1800
NS foo.com directs to ns2.digitalocean.com. 1800
NS foo.com directs to ns3.digitalocean.com. 1800


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This comment has been deleted

You’ll have to verify who’s redirecting your domain. Is there any app running there?

If you use python (and requests library) try this

C:\Users\Alexei>python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> r = requests.get('http://amdb.com.br')
>>> print r.history
[<Response [301]>]
>>> print r.history[0].headers
{'Content-Length': '178', 'Server': 'nginx', 'Connection': 'keep-alive', 'Location': 'https://www.amdb.com.br/', 'Date': 'Wed, 18 Oct 2017 11:13:34 GMT', 'Content-Type': 'text/html'}

Inspecting all history entries’ headers, you’ll get some hint about who’s redirecting. In this example, nginx itself. I believe your problem isn’t in the DNS, because it doesn’t make redirections. Servers and applications do.

Delete 1st and 3rd entries and add a CNAME value www to server @ (yes, just @)

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.