Mac OS Lion – Wildcard subdomain virtual host

I am trying to get WordPress 3.3.1 multisite (sub-domains) working in my localhost. However, it appears that I need to have wildcard subdomains configured for my WordPress vhost. The idea is to have any_subdomain.my_wordpress.local to go to my_wordpress.local.

How do I do this in Mac OS 10.7.3 with Apache 2.2.22?

Read More

This is the virtual host set up in my http-vhosts.conf file for that local site:

<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

I have also added wordpress_mu into /etc/hosts.

127.0.0.1  wordpress_mu

Thank you in advance.

Related posts

Leave a Reply

1 comment

  1. /etc/hosts doesnt support wildcards so you need to add each subdomain to your /etc/hosts otherwise it wont work.

    Alternatively, you can run a DNS server somewhere on your local network whether thats your local machine, another box, or your router. dnsmasq is pretty easy to setup. If you have a wireless router that supports ddwrt then you can even run it on there. That way you can just use a wildcard.