0

I'm trying to add subdomain to my domain. I just installed httpd on my clean centos 7. At first I created file /etc/httpd/conf.d/htmltest.mydomain.com.conf with the following contents:

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin [email protected]
  ServerName  htmltest.mydomain.com
  DirectoryIndex index.html index.php
  DocumentRoot /www/sites/htmltest.mydomain.com/htdocs
  # Log file locations
  LogLevel warn
  ErrorLog  /www/sites/htmltest.mydomain.com/log/error.log
  CustomLog /www/sites/htmltest.mydomain.com/log/access.log combined
</VirtualHost>

<Directory "/www/sites/htmltest.mydomain.com/htdocs">
    Options Indexes FollowSymlinks
    AllowOverride None
    Require all granted
</Directory>

Also /www/sites/htmltest.mydomain.com/htdocs folder was created with index.html file inside. With this configuration my attempt to access htmltest.mydomain.com gives 'server DNS address could not be found' error in the browser. But mydomain.com opens htmltest subdomains index.html. In my hosting CP dns settings there is mydomain.com with the htmltest 'A' record pointing to server IP, along with the www record. How can I fix this?

UPD: I've changed domain to use vultr nameservers, and it works properly now.

2
  • Can you post a screenshot of the DNS entries from your hosting CP? I'm having a hard time understanding how you have that set up without being able to see it. But it sounds like you have two A records: htmltest.mydomain.com and www.mydomain.com where you want a single A record: www.htmltest.mydomain.com. Mar 19, 2016 at 2:43
  • @CodingGorilla, please see attached screenshot Mar 19, 2016 at 3:26

1 Answer 1

1

Ok so based on your screenshot, you have 2 different URLs for your website, the possible host headers you could use would be:

htmltest.mydomain.com

www.mydomain.com

This is not what you want though, you want:

www.htmltest.mydomain.com

So you should delete the first two (unless you want to keep them, which is perfectly valid), and add www.htmltest.mydomain.com as an A record with the appropriate IP address.

Just a word of caution though, you may need to check with your hosting provider; sometimes simply adding a host record as above (with the subdomain) may not be all that is required to make this work. As I don't know your hosting provider, I cannot say for sure, but generally this approach will work.

2
  • thank you for your help, I've changed domain to use hosting nameservers, and it works properly now. Mar 19, 2016 at 4:34
  • Right now subdomains are working as they should, but www prefix points to one of my subdomains, how can I alias www to second-level domain? Do I need to create www.domain.com.conf file or there is another way to alias? Mar 19, 2016 at 4:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .