Cristiam Mercado
Cristiam Mercado

Reputation: 582

Configure server to point subdomain to specific folder?

I have a hosting with cPanel where I have my domain registry (for example: www.mydomain.com). I have an EC2 instance with Bitnami LAMP where my app is running, and there is another folder with a second app. This is the structure:

/opt/bitnami/apps/myapp   (main app)    (www.mydomain.com)
/opt/bitnami/apps/myapp2  (second app)  (www.mydomain.com/myapp2)

I pointed the domain www.mydomain.com from hosting with cPanel to EC2 instance static IP using cPanel Advanced Zone Editor to my main app:

Name                TTL    Class    Type    Registry
www.mydomain.com    14400  IN       A       123.456.789.012

I don't have problems with it.

The problem is: How I can point a subdomain, for example: test.mydomain.com or secondapp.mydomain.com to the second app? I read modifying Apache virtual hosts file, but I'm not sure about that.

Thanks a lot!

Upvotes: 0

Views: 1535

Answers (2)

Jota Martos
Jota Martos

Reputation: 4714

Bitnami developer here,

You have to modify the httpd-vhosts.conf file of your application and set the ServerName and ServerAlias. You also have to include that file in the main configuration file of Apache.

You will find more information using the following link

https://wiki.bitnami.com/Components/Apache?highlight=apache#How_to_create_a_Virtual_Host.3f

Finally you will need to configure your domain provider to point to those subdomains.

I hope it helps.

Jota

Upvotes: 1

Spencer Bravo
Spencer Bravo

Reputation: 31

You will want to modify your Apache virtual hosts file. That is where you can set what domains(and subdomains) point where on your server. Depending on your server this will be in "/etc/httpd" or "/etc/apache2".

You can find vhost examples here: https://httpd.apache.org/docs/2.2/vhosts/examples.html

Hope this helps

Upvotes: 1

Related Questions