Existing Subdomains

How do I implement existing sub domains. So I want forums.domain.com to goto bbpress and not mu. I have this in my .htaccess. With bbpress being a symlink under mu pointing to bbpress

RewriteCond %{HTTP_HOST} forums.domain.com
RewriteCond %{REQUEST_URI} !forums/
RewriteRule ^(.*)$ bbpress/$1 [L]

result is : forums.domain.com/bbpress . I want forums.domain.com .

  • Luke
    • The Crimson Coder

    Easiest way is to have the virtual host for "forums.domain.tld" come before the main MU virtual host in your httpd.conf file.

    Then the forum would have it's own path on the file system, separate from the MU file path. Plus you skip the additional overhead from the htaccess addition.

  • johnnytee
    • Design Lord, Child of Thor

    Hey Luke,

    I did this and it works great but now my mapped domains go to the forum... Any ideas on how to avoid this. According to the Domain Mapping plugin "Make sure the default Apache virtual host points at your WordPress MU site so it will handle unknown domains correctly."

    Right now forums is the default since it comes first?

  • Luke
    • The Crimson Coder

    That's interesting.
    Here's a stripped down example of two virtual hosts within httpd.conf.

    The following example would be for a server with an MU site, another website, and a forums subdomain.

    # forums
    <VirtualHost *>
    DocumentRoot /path/to/forums
    ServerName forums.domain.tld
    <Directory /path/to/forums>
    Options -Indexes FollowSymLinks Multiviews
    AllowOverride FileInfo Options
    </Directory>
    ErrorLog /path/logs/forums/error_log
    TransferLog /path/logs/forums/access_log
    </VirtualHost>

    # another website
    <VirtualHost *>
    DocumentRoot /path/to/other_site
    ServerName other-domain.tld
    ServerAlias http://www.other-domain.tld
    <Directory /path/to/other_site>
    Options -Indexes FollowSymLinks Multiviews
    AllowOverride FileInfo Options
    </Directory>
    ErrorLog /path/logs/other_site/error_log
    TransferLog /path/logs/other_site/access_log
    </VirtualHost>

    # MU (gotta come last, to be safe)
    <VirtualHost *>
    DocumentRoot /path/to/mu_site
    ServerName domain.tld
    ServerAlias *.domain.tld domain2.tld http://www.domain2.tld http://www.domain3.tld http://www.domain3.tld
    <Directory /path/to/mu_site>
    Options -Indexes FollowSymLinks Multiviews
    AllowOverride FileInfo Options
    </Directory>
    ErrorLog /path/logs/mu_site/error_log
    TransferLog /path/logs/mu_site/access_log
    </VirtualHost>

    A few notes on the above. The forum vhost comes first, the "other" website second. Finally, MU comes last.

    The MU one assumes you have 3 domains, two of which are mapped but do not have subdomains associated with them. YMMV.

    If you have a ton of mapped domains, there's an easier way to do the above. But an average setup only has a hand full, so I used that as a reference instead.

    If you have a "default" virtual host, you can make it the last one in the list.

    Of course, don't forget to restart apache either. :smiley:

  • Ovidiu
    • Code Wrangler

    If you have a "default" virtual host, you can make it the last one in the list.

    just wanted to mention that Donncha recommends this setting:

    Make sure the default Apache virtual host points at your WordPress MU site so it will handle unknown domains correctly. (Need info on cpanel, etc. How do you get them to respond to any domain?)

    http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/installation/

    I have been struggling with something similar too, so please follow up this psot with suggestions if you find any solutions. thx.

  • johnnytee
    • Design Lord, Child of Thor

    I ended up not using forums.domain.com instead I have domain.com/forums.

    I did this because the solution Luke proposed

    ServerAlias *.domain.tld domain2.tld http://www.domain2.tld http://www.domain3.tld http://www.domain3.tld

    worked , but I don't want to have to add the domain into the config every time I add a new one.

    Also it screwed up the single sign on. But if you don't mind adding in the domains , Luke's solution does work.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.