Mac OS Lion - 通配符子域虚拟主机

ban*_*aus 3 wordpress wildcard-subdomain osx-lion

我试图在我的localhost中使用Wordpress 3.3.1多站点(子域).但是,似乎我需要为我的Wordpress vhost配置通配符子域.我们的想法是将any_subdomain.my_wordpress.local转到my_wordpress.local.

如何在Mac OS 10.7.3中使用Apache 2.2.22执行此操作?

这是在我的http-vhosts.conf文件中为该本地站点设置的虚拟主机:

<VirtualHost *:80>
    DocumentRoot "/Users/some_user/Sites/wordpress_mu"
    ServerName wordpress_mu
    ServerAlias *.wordpress_mu
    ServerAdmin some@email.com

# Logging
    ErrorLog "logs/wordpress_mu.error_log.log"
    CustomLog "logs/wordpress_mu.access_log.log" combined

<Directory "/Users/some_user/Sites/wordpress_mu">
    RewriteEngine On

    # To allow permalink as specified by wordpress admin interface
    RewriteBase /
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 

            Options FollowSymLinks MultiViews Includes ExecCGI
            AllowOverride All 
            Order allow,deny
            Allow from all 
    </Directory>

    # Set valid directory pages
    DirectoryIndex index.html index.htm index.shtml index.php
Run Code Online (Sandbox Code Playgroud)

我还在/ etc/hosts中添加了wordpress_mu.

127.0.0.1  wordpress_mu
Run Code Online (Sandbox Code Playgroud)

先感谢您.

pro*_*son 5

/etc/hosts不支持通配符,所以你需要添加每个子域到/etc/hosts否则它不会工作.

或者,您可以在本地网络上的某个位置运行DNS服务器,无论是本地计算机,另一个计算机还是路由器.dnsmasq很容易设置.如果您有支持的无线路由器,ddwrt那么您甚至可以在那里运行它.这样你就可以使用通配符.