Using a directory in VirtualHost ServerName

放肆的年华 提交于 2019-12-29 03:05:11

问题


I'm currently using name-based virtual host configuration, to server about 5 different websites from the same IP address, just like in the apache documentation:

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

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

Is it possbile to have something like:

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

The webpages in this folder are using a different software stack, and I'd like to keep it nicely separate. I tried the method above but it didn't work.


回答1:


It's not possible the way you show - a VirtualHost is always just a host. But you could use an Alias.

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

Alias /folderpath /www/software

</VirtualHost>



回答2:


Is it possible to have a different vhost for each application like that:

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

<VirtualHost *:80>
ServerName www.domain.tld
Alias otherApp /www/otherApp
</VirtualHost>


来源:https://stackoverflow.com/questions/5552081/using-a-directory-in-virtualhost-servername

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!