Adding a subdomain to virtual host

Keywords: LAMP/MAMP/WAMP - AWS - How to - Other
Description:
Hello, I need to add a subdomain to my website’s Vhost. these code is the current Vhost before adding the subdomain and works well:

<VirtualHost 127.0.0.1:80 default:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
RewriteRule ^(.
)$ http://%1$1 [R=permanent,L]
ServerName mydomain.com
ServerAlias mydomain.com www.mydomain.com
DocumentRoot /opt/bitnami/apps/main
Alias /fa/ “/opt/bitnami/apps/farsi/”
Alias /fa “/opt/bitnami/apps/farsi”
<Directory “/opt/bitnami/apps/main”>
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted

<Directory “/opt/bitnami/apps/farsi”>
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted

I am wondering where the subdomain alias and directory should be added. I tried to follow the bitnami’s guide but I got confused as there are some other aliases.

the subdomain address is “portal.mydomain.com” and the directory is “/opt/bitnami/apps/portal”

Thank you in advance for your help.

Hi @Chicago,

Thanks for your message. As this is a different domain or subdomain, you will need to create a new virtualhost for this application where ServerName gets the portal.mydomain.com value. I would add it in a different .conf file as well.

If you continue having issues after following these steps, please run the bnsupport tool and create a new thread in the forum for a “Technical issue” instead of a “How to”.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.