【问题标题】:Mac OS Lion - Wildcard subdomain virtual hostMac OS Lion - 通配符子域虚拟主机
【发布时间】:2023-06-12 14:49:01
【问题描述】:

我正在尝试让 Wordpress 3.3.1 多站点(子域)在我的本地主机中工作。但是,看来我需要为我的 Wordpress 虚拟主机配置通配符子域。我们的想法是让 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

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

127.0.0.1  wordpress_mu

提前谢谢你。

【问题讨论】:

    标签: osx-lion wildcard-subdomain wordpress


    【解决方案1】:

    /etc/hosts 不支持通配符,因此您需要将每个子域添加到您的/etc/hosts 否则它将无法工作。

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

    【讨论】:

      最近更新 更多