I have 2 completely different projects I would like to host from the same domain name "mysimpledomainname.com" with ip address xx.xx.xxx.xx (not local)
The 2 projects are located at Project 1) /var/www/html/project1 Project 2) /var/www/html/project2
I would like to have the 2 projects resolve like this
mysimpledomainname.com
mysimpledomainname.com/project2
I DO NOT want to use subdomain names. This is for a project on my public server, not my local machine, so I don't think updating the host file will help me.
I already have the first project loading from mysimpledomainname.com (it's already working).
In the directory sites-available I have the conf file mysimpledomainname.com.conf with values:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/project1
<Directory /var/www/html/project1/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I think I need to have 2 different conf files set up in order to do this, but after searching around I have not been able to find a solution. Can anyone help me with this? Rather than giving a short answer can you post exactly what I would need for the 2 different conf files?
Thanks,
David
You can have only 1 VirtualHost directive as this is defined per FQDN and you want to use only mysimpledomainname.com.
Your config for Project1 is OK. You just need to make available another directory under path /project2. To do this, you need to use the Alias directive.
So your final config should be something like this (of course you can have separate Directory configurations for each subdir if you want):
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/project1
Alias /project2 /var/www/html/project2
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With