Mobile app version of vmapp.org
Login or Join
Turnbaugh106

: How do you set DNS record so that www subdomain is set to root domain? I don't want "www" in my domain. How do I set dns record so that when someone types www.mydomain.com it will just

@Turnbaugh106

Posted in: #Dns

I don't want "www" in my domain. How do I set dns record so that when someone types mydomain.com it will just show up as mydomain.com?

I just want www to foward to root domain? Tried searching but google only tells me how to make my domain "www" which I do not want.

Is DNS even what I should be looking at?

Tool Tips is telling me, "The question you're asking appears subjective and is likely to be closed"...

Look, I don't know how to ask the question any different. I thought this could be done on a DNS level without messing with htaccess.

Any help would be appreciated.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Turnbaugh106

2 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

While people expect not having to type the , most web servers will add it once you connect to them because that is its canonical name. Try it with google; typing google.com into your browser takes you to google.com.
But try this: configure your web server to accept example.com and example.com as acceptable names, with example.com as the canonical name, i.e. for Apache2:

ServerName example.com
ServerAlias example.com

Then, for a hosted DNS setup, configure your DNS for the domain so that the @ record is an A record with your IP address and www record is a CNAME for example.com.

If you're using bind text config files, try something like this to use the same host at IP 1.2.3.4 as the www server and domain origin:

$ORIGIN .
$TTL 43200 ; 12 hours
example.com IN SOA ns.example.com. root.example.com. (
201511496 43200 7200 604800 3600 )
$TTL 604800 ; 1 week
NS ns1.example.com.
A 1.2.3.4
$ORIGIN example.com.
# web server is hosted on same host as domain origin
www CNAME example.com.


To then FORCEFULLY redirect example.com to example.com regardless of what the user expects, use a rewrite rule in your web server. For example, in Apache2:

RewriteCond %{HTTP_HOST} !^example.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) example.com/ [L,R]


For further Apache2 rewrite examples and for non-port 80 hosts, see httpd.apache.org/docs/2.4/rewrite/remapping.html

10% popularity Vote Up Vote Down


 

@Berumen354

There is no DNS record under the RFC which will forward your connection to the non-www version of your site. The traditional way to do this is to set your web server IP as an A record for your zone apex and then set www as a CNAME record referencing the zone apex of your domain but you specifically say that you do not wan't to do this. In this case the only way to do what you are wanting is through code, more specifically, setting up a site under www with only a .htaccess file on it and set it up to do a 301 redirect to your zone apex site but to be honest this is not the best practice to do and understand that most users on the internet don't understand DNS or routing and would expect to see the www there if they are trying to access the site.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme