I'm having trouble pointing a domain name to a subdirectory on an Amazon EC2 instance.

FYI - I'm not too experienced with DNS or networking ...

So jumping right in ...

  • I set up an Amazon EC2 instance with an elastic IP, for example, ""

  • Edit: Apache2 server is installed on the instance.

  • I put a site under a folder, for example, "/var/www/html/website"

  • I have a domain name, for example, "example.com"

  • I've set up Route 53 with a hosted zone "example.com" with an A record that points to ""

So when I go to "example.com", I get the Amazon Test Page.

How would I get "example.com" to point to the "/var/www/html/website" folder

Any help would be appreciated!

Edit: One thing I forgot to mention is that I have other folders for different websites that I want different domain names to point too. Eg. "example.com" points to "/var/www/html/website1" AND "example2.com" points to "/var/www/html/website2"

  • 1
    Valid example websites are example.{com|net|org}, if you want to use those.
    – TRiG
    Sep 20, 2013 at 15:20

2 Answers 2


I'm assuming you're using the default Apache2 available on EC2's default Amazon distro of Linux... you didn't state, so I don't know for sure. You could be using nginx for all I know, in which case these instructions are wasted.

You need to edit /etc/httpd/httpd.conf or /etc/apache2/apache2.conf (whichever one exists) and change your virtual host configuration. See the Apache reference guide for details. It even has some examples.

Generally, you'll need to remove or repurpose any existing <VirtualHost ... blocks and make sure you have something like this in your config:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
  • The above instruction is correct. I would add- keep your DocumentRoot name and ServerName same. It did not work for me until I renamed so that both matched.
    – Syed Priom
    Feb 8, 2014 at 22:18
  • 2
    For Amazon Linux, it's /etc/httpd/conf/httpd.conf
    – Richard Fu
    Mar 25, 2019 at 8:56

If you have created a subdomain and want to point it to the


go to /etc/apache2/sites-available

then you need to make example.website.in.conf file and edit the values

You can find a default copy 000-default.conf of the configuration in the folder

Enable the site by sudo a2ensite example.website.in

more here https://docs.rackspace.com/support/how-to/set-up-apache-virtual-hosts-on-the-ubuntu-operating-system/

  • Welcome to Super User! Before answering an old question having an accepted answer (look for green ✓) ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also a site tour and a help center. Feb 17, 2023 at 10:30

You must log in to answer this question.

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