-1

I am trying to point my subdomain to an EC2 Server.

I added the following DNS entries on my registry.

  • A Record test1 => EC2 Elastic IP Address
  • C Name test2 => xxxxx-amazonaws.com

When I test them, both test1.example.com and test2.example.com go to the EC2 Server. However, the address in the web browser changes to xxxxxx-amazonaws.com.

How can I keep them as test1.example.com and test2.example.com?

kasperd
  • 30,455
  • 17
  • 76
  • 124
Kelvin
  • 103
  • 2
  • thank you for the reply. i am using apache i think. does this require me changing the http.conf or the .htaccess file? i am not sure how to go about solving this. – Kelvin May 29 '17 at 07:33
  • you're right, both the Location: is the http://xxxxx.amazonaws.com/ – Kelvin May 29 '17 at 07:34
  • sure i can, can you teach me what i have to do for that? – Kelvin May 29 '17 at 07:37
  • 1
    Based on everything you've said, I think you need to hire someone to help you with this. – Tim May 29 '17 at 08:12

1 Answers1

1

The address in the browser is changed by a redirect coming from your WebServer. They do that if they think they need you redirect to a URL ending in a slash, or generally recognize a mismatch in the requested hostname and the name the server thinks it has.

You need to turn those redirects off, make them relative or use the actual requested hostname. This is normally part of setting up a name-based virtual host.

You can see that behavior if you look at the web response in browser developer tools. Check the Location: header. Most likely the redirect is trying to add a trailing slash.

With the Apache httpd it might be enough to set the ServerName config to your possible domain names. This might remove the redirect (which would be the best case) or at least make it redirect to the correct target.

eckes
  • 845
  • 9
  • 21
  • i changed Servername to test.mydomain.com but its still the same. noticed the status code when i go to test.mydomain.com is Status Code:301 Moved Permanently (from disk cache) – Kelvin May 29 '17 at 07:49
  • Yes 301 is expected. Make sure you changed the servername in all places if the config defines multiple servers or vhosts. I think turning on extended server info in Apache helps to find the aggregated current config. There you can search for the AWS-name and know what else you need to change. – eckes May 29 '17 at 09:43