WPMU Subdomain htaccess and cPanel

July 21, 2006

In my homepage in last year 2005, i used to install WPMU. After i changed to my server, i dropped WPMU beta testing path. When i have enough time again, i will join the WPMU testing path again. The time when i used WPMU, i hosted on cPanel just as normal hosting packages like those hosting company offered. I have to submit support ticket to my hosting company about doing the following for me.

Apache mod_rewrite
Normally, hosting offered this feature in default. I did not need to request. You may test with phpinfo() to check this feature whether available or not.

Zone name and Apache config edit
On Linux platform,

Goto
/var/named/yourdomain.com.db

add this at the end of file

*.yourdomain.com. 14400 IN A 12.34.56.789

restart BIND

/etc/init.d/named restart

and go to

/etc/httpd/conf/httpd.conf

add wildcard character “*” asterisk at server alias

DocumentRoot /home/username/public_html
BytesLog domlogs/yourdomain.com-bytes_log
User username
Group username
ServerAlias www.yourdomain.com yourdomain *.yourdomain.com
ServerName www.yourdomain.com
CustomLog domlogs/yourdomain.com combined

What i have encountered is that in Apache config, at ServerAlias field, if i didn’t put all three factors of your domain in above manner, you will end up with sort of cPanel no config page. You must add all three factors not just asterisk entry. After your server admin did as accordingly, you will probably can run WPMU :-) . But the normal httpd server may not be sensitive.

After that all new blog account will create as what WPMU does accordingly. But somehow you still wanted to load in subdomain as other scripts or web application, you can do so. For example, let’s say, you offer multi blogging service and want to build support forum or wiki as subdomain, you have to normal procedure way of installing that forum or wiki. After that here is what you have to do in your htaccess to offer that forum or wiki as subdomain.

RewriteCond %{HTTP_HOST} wiki.haalaaluu.com
RewriteCond %{REQUEST_URI} !wiki/
RewriteRule ^(.*)$ wiki/$1 [L]
RewriteCond %{HTTP_HOST} forum.haalaaluu.com
RewriteCond %{REQUEST_URI} !forum/
RewriteRule ^(.*)$ forum/$1 [L]

Suppose your rewrite base is /. The complete config may look like this:

#htaccess start, please do not copy this line

RewriteEngine On
RewriteBase /

# Rewrite www.domain.com to domain.com (default WPMU config)
RewriteCond %{HTTP_http://www.haalaaluu.com} ^www\.(.*)
RewriteRule ^(.*)       http://%1/$1 [R,L]

# None WPMU subdomains (put outside of WPMU subdomains here)
RewriteCond %{HTTP_HOST} wiki.haalaaluu.com
RewriteCond %{REQUEST_URI} !wiki/
RewriteRule ^(.*)$ wiki/$1 [L]

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

# Ultimate Tag Warrior (put whatever 3rd party plugin config)
RewriteRule ^tag/(.+)$ /index.php?tag=$1 [QSA,L]

###
#### blogs (all the way under this section is default WPMU config)
###


#htaccess end, please do not copy this line

Hello world!

November 27, 2005

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!


Follow

Get every new post delivered to your Inbox.