Virtualhost For Wildcard Subdomain and Static Subdomain

前端 未结 3 1613
感动是毒
感动是毒 2020-11-27 09:40

I have an odd situation where I want to have the URLs app1.example.com, example.com and *.example.com all using a different virtual h

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 10:27

    Wildcards can only be used in the ServerAlias rather than the ServerName. Something which had me stumped.

    For your use case, the following should suffice

    
        ServerAlias *.example.com
        VirtualDocumentRoot /var/www/%1/
    
    

    There is also more information at https://www.chris-shaw.com/blog/using-wildcards-in-virtual-hosts-on-apache

提交回复
热议问题