How do I map a subdomain to WordPress Posts?

Slightly strange question, I want my WordPress blog to use subdomains as permalinks, a bit like the popular website “The Setup“.

I already have Apache configured to load the site irrespective of the subdomain, I just need to work out how to make WordPress load the right post. I have my permalink structure set as “/%postname%/” as I will manually ensure the post names are unique.

Read More

All I need to work out is how to get the subdomains mapped to the postname – I’m guessing it requires mod_rewrite? But I’m unsure how to proceed.

Thanks

Related posts

Leave a Reply

2 comments

  1. I’m using nginx for The Setup, so I’m not sure if that will help you much at all (nor can I guarantee that this is the best way to do it) but my config looks something like this:

    location = / {
    
            if ($host ~* "^([a-z0-9+.-]+).usesthis.com$") {
                set $interview $1;
            }
    
            if ($interview !~* '^(www)?$') {
                rewrite ^(.*)$ /interviews/$interview.html;
            }
        }
    }
    
  2. The best way to accomplish this with WordPress core features seems to be the “Create a Network” feature – formerly WordPress Multi-Site (MU).

    All you have to do is add a line to your wp-config.php file to begin the setup options from the WordPress dashboard.

    There are details here: http://codex.wordpress.org/Create_A_Network

    However, be advised that at this time they are slightly out of date in terms of what the screens look like, and the workflow. (For example, once you’ve gone through the process, now instead of entering the Network Admin interface from the top left link in the admin dash bar, the link is in the top right and looks a bit different).