-1

I have a website hosted on the following path: mywebsite.com/test with the following DNS

mywebsite.com            A   1.2.3.4 (host ip)
host.mywebsite.com       A   1.2.3.4 (host ip)

On another domain I'm trying to make a subdomain CNAME redirect to this page using the following:

link.myotherdomain.com   CNAME .  mywebsite.com/test

However when I access link.myotherdomain.com it shows the host.mywebsite.com instead of mywebsite.com

I'm doing something wrong?

Thanks

set0gut1
  • 1,652
  • 1
  • 8
  • 21

1 Answers1

1

CNAME record cannot include path. It only for domin to domain. This setting will work.

link.myotherdomain.com.   CNAME   mywebsite.com.

If configured properly, all of mywebsite.com host.mywebsite.com link.myotherdomain.com are resolve to 1.2.3.4, then the following HTTP request is sent to IP address 1.2.3.4.

GET /test HTTP/1.1
Host: link.myotherdomain.com
......(omit)

Now, the most suspiicious element is the Virtual Host setting of webserver. This is a function of the web server that behaves as if it is a different server according to the Host value in the request header.

To survey about Virtual Host, the following might be the most simple method.

  • curl -H 'Host:mywebsite.com' http://1.2.3.4/test // this will ok
  • curl -H 'Host:link.myotherdomain.com' http://1.2.3.4/test // this will not ok if Virtual Host enabled
set0gut1
  • 1,652
  • 1
  • 8
  • 21
  • Hello! Sure that's how I'm using it however if I try to access mywebsite.com/test on the browser I see the message "File not Found". I think it's redirecting to the wrong folder of my server, but I don't know where I can change it – Felipe Michelin May 02 '18 at 22:23
  • I added my answer. Isn't your web server enabled the Virtual Host setting? – set0gut1 May 02 '18 at 22:36