0

I have a website "example.com" hosted on a provider that allows me to manage my own DNS. I want example.com to point to the provider's IP address but I want "subdomain.example.com" to point on my own apache installation on a VPS I have with, of course, a different IP address.

This is what I have done:

I set the A redirect of example.com to the provider's machine (let's say IP is 1.2.3.4)

I set the A redirect of subdomain.example.com to my own VPS (let's say IP is 5.6.7.8)

Then I connected to my VPS server and changed my apache files like this:

httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs\mydirectory\mysubdirectory"
    ServerName subdomain.example.com
    <Directory "C:\xampp\htdocs\mydirectory\mysubdirectory">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

hosts file, I add:

127.0.0.1       subdomain.example.com

However when I ping subdomain.example.com I get an "Unknown host error", nor I can access from my own VPS to the files by browsing that URL.

Am I missing something important?

1 Answer 1

2

You have to create a separate A record in your mydomain.com's DNS zone file to point your subdomain to your VPS's IP.

subdomain A 5.6.7.8

If you want, you can add the complete hostname subdomain.domain.com as long as it is followed by a . (dot).

subdomain.domain.com. A 5.6.7.8

4
  • Oh.. just the subdomain? I wrote the entire address: subdomain.mydomain.com. I'll try this out and let you know, maybe this is what I was doing wrong. Thanks
    – wiredmark
    Dec 17, 2014 at 12:15
  • This is almost certainly what is wrong, but it may be worth clarifying your answer to explicitly explain that the record data should only contain subdomain and not subdomain.domain.com for any future readers
    – BE77Y
    Dec 17, 2014 at 12:17
  • @wiredmark - you can write the entire address as long as it is followed by a . (dot). @BE77Y I will update the answer.
    – Sreeraj
    Dec 17, 2014 at 12:35
  • Thanks, now I understand what the final dots I already saw somewhere mean!
    – wiredmark
    Dec 17, 2014 at 13:53

You must log in to answer this question.

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