Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm on an EC2 instance and have a domain linked to the EC2 nameservers and it happily is serving my pages if I type in the URL.

However when the page is served it resolves the url to:

Using apache I've set up the following VirtualHost, following examples provided at

Listen 80


DocumentRoot /var/www/html/directory

# Other directives here ...

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"

However I'm not getting any changes to how the URL is displayed.

This is the only VirtualHost configured on this site and I've confirmed its the one being used as I've managed to break it a number of times whilst experimenting with the configuration.

The route53 entries I have are: A NS    SOA 1 1100 100 1101100 11100
share|improve this question
The pages are served if you type, but it is "resolving" to XYZ "However I'm not getting any changes to how the URL is displayed." - Are you being redirected to XYZ, which is causing the URL to change?? – w3d Feb 9 '14 at 10:27
...what do you mean by "resolving"? – w3d Feb 9 '14 at 11:48
i type and it directs me to 1111.11.11.11/directory/file.php. By resolve I just mean it redirects me to the url, probably just my poor terminology. I'm new to this type of work – sapatos Feb 9 '14 at 23:19
If you are being redirected to a different URL then I can't see how this relates to the VirtualHost/DNS settings mentioned - this would seem to be unrelated? – w3d Feb 9 '14 at 23:32
the location it directs me to is correct, however I'd like it to remove the 1111.11.11.11 and replace it with – sapatos Feb 10 '14 at 4:17

2 Answers 2

First, use <VirtualHost *:80> instead of <VirtualHost>. That way your virtual host applies no matter what the IP address of your server is.

Second, you need to issue a redirect if the host name isn't what you expect. I would recommend having two virtual hosts. The first is the default one for any unexpected domain names or IP addresses. It can issue a redirect to the correct domain name. The second one should be the one for your domain name. Something like:

<VirtualHost *:80>
    ServerName localhost.localdomain
    Redirect permanent /

<VirtualHost *:80>
    DocumentRoot /var/www/html/directory

    # Other directives here ...
share|improve this answer

You'll need to set up a DNS record on the server - an A record using the IP address as the destination/target.

As an example, in your VirtualHost file, you should have something like:-

<VirtualHost *:80>
DocumentRoot "/var/websites/domain/"
ErrorLog "/var/websites/domain/logs/error.log"
CustomLog "/var/websites/domain/logs/access.log"

Obviously the above needs amending to the relevant paths on your server accordingly based on how you have it set up (you may need to create the necessary directories if they don't already exist).

Then you'd need to restart the server with service httpd restartfor the changes to take affect. Whether this differs on an EC2 instance I'm unsure, but this is what is needed on an Apache server.

share|improve this answer
thanks Geoff, I've tried the same and I'm getting a '404 not found'. On EC2 I've got an A record in my route53 record set pointing at Is this the DNS record you mean. I wasn't sure if you meant a DNS record on the actual server it's running on or the route53 server? – sapatos Feb 9 '14 at 10:06
it seems to only work if the ip address is in the VirtualHost tag – sapatos Feb 9 '14 at 10:09
Yes, the A record needs to be created in Amazon's DNS service route 53. Can you confirm what DNS records you have currently set up? – zigojacko Feb 9 '14 at 10:35
updated with records. I notice that I specified the name as not I remember this being recommended and I tried adding some entries in case that was the fix and it didn't work. – sapatos Feb 9 '14 at 23:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.