I have an Ubuntu Server with a standard apache 2.4 installed that get its content from /var/www/html. So every html page I have is accessed by http://example.com/index.html ... Now i want a separate Directory /var/app1/html that holds another web-project and that can be accessed by http://example.com/application1/ I have tried to setup a different conf. file under /etc/apache2/sites-enabled with the following content
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/app1/html
<Directory /var/app1/html>
AllowOverride None
Require all granted
Allow from All
</Directory>
</VirtualHost>
However if I do not know how to setup the name application1 so that example.com/application1 links to /var/app1/html
Best regards
P0nch0
I put both configurations in one conf file (Not sure if that will make a difference for you). You should be able to link app1 to the directory by changing the ServerName of app1 to include the path. For Instance:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/app1/html
<Directory /var/app1/html>
AllowOverride None
Require all granted
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.com/app2
ServerAlias www.example.com/app2
DocumentRoot /var/app2/html
<Directory /var/app2/html>
AllowOverride None
Require all granted
Allow from All
</Directory>
</VirtualHost>
If you are wanting to connect to the app using any other domains on top of ServerName you should use ServerAlias. For instance:
<VirtualHost *:80>
ServerName example.com/app2
ServerAlias example2.com www.example2.com
DocumentRoot /var/app2/html
<Directory /var/app2/html>
AllowOverride None
Require all granted
Allow from All
</Directory>
</VirtualHost>
It may be more beneficial to setup this configuration using subdomains instead: app2.example.com
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.