Apache default VirtualHost

前端 未结 9 1639
忘掉有多难
忘掉有多难 2020-12-05 17:53

how can I set a default VirtualHost in apache? Preferably, I want the default host not to be the same as the ip address host. Now I have something like this:



        
9条回答
  •  既然无缘
    2020-12-05 18:07

    The other answers here didn't work for me, but I found a pretty simple solution that did work.

    I made the default one the last one listed, and I gave it ServerAlias *.

    For example:

    NameVirtualHost *:80
    
    
        ServerName www.secondwebsite.com
        ServerAlias secondwebsite.com *.secondwebsite.com
        DocumentRoot /home/secondwebsite/web
    
    
    
        ServerName www.defaultwebsite.com
        ServerAlias *
        DocumentRoot /home/defaultwebsite/web
    
    

    If the visitor didn't explicitly choose to go to something ending in secondwebsite.com, they get the default website.

提交回复
热议问题