What DNS record should be configured to use a domain name without www?

If I have the domain name example.com , and if I set the A record for www , www.example.com will return the IP address specified in the A record. And what should I configure if I want to allow example.com (without www. ) to the IP address?

+4
source share
2 answers

Adjust DNS settings for example.com. Make sure you have address records (type A records) for example.com and www.example.com with the same IP address.

If you use shared hosting to provide multiple websites at the same IP address, you also need to tell the web server about the alternate name for the site. In the configuration of your web server, add example.com as an alias for www.example.com. In the Apache server httpd.conf file, this usually looks like this:

 <VirtualHost *> DocumentRoot /home/www/web ServerName www.example.com ServerAlias example.com </VirtualHost> 

http://www.boutell.com/newfaq/creating/withoutwww.html

+2
source

Usually you also redirect:

Apache configuration

 RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule ^(.*) http://www.example.com/$1 [R=301,L] 
+1
source

Source: https://habr.com/ru/post/1402903/


All Articles