Wildcard domains with virtualhost with Apache on Mac

后端 未结 2 1347
醉话见心
醉话见心 2021-01-22 12:33

I\'m currently running several domains for local development

http://wordpress.dev
http://phpmyadmin.dev
http://projectx.dev
http://projecty.dev
...
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-22 13:27

    In order to accomplish what you need, you can configure a dynamically configured mass virtual host.

    To have it you should add something like the following to your httpd.conf file:

    # get the server name from the Host: header
    UseCanonicalName Off
    
    # this log format can be split per-virtual-host based on the first field
    LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
    CustomLog logs/access_log vcommon
    
    # include the server name in the filenames used to satisfy requests
    VirtualDocumentRoot /www/hosts/%0/docs
    VirtualScriptAlias /www/hosts/%0/cgi-bin 
    

    That would do the same as the following:

    NameVirtualHost 111.22.33.44
    
        ServerName www.customer-1.com
        DocumentRoot /www/hosts/www.customer-1.com/docs
        ScriptAlias /cgi-bin/ /www/hosts/www.customer-1.com/cgi-bin
    
    
        ServerName www.customer-2.com
        DocumentRoot /www/hosts/www.customer-2.com/docs
        ScriptAlias /cgi-bin/ /www/hosts/www.customer-2.com/cgi-bin
    
    # blah blah blah
    
        ServerName www.customer-N.com
        DocumentRoot /www/hosts/www.customer-N.com/docs
        ScriptAlias /cgi-bin/ /www/hosts/www.customer-N.com/cgi-bin
     
    

    For more details on this, check here

提交回复
热议问题