VPS: Hosting WordPress and Flat Websites Together with Apache #2

I did say

*Disclaimer: I’m not (and don’t claim to be) an expert. This could break things, upset your granny or otherwise not do what you want. I’m happy to receive corrections or improvements – or thanks if it works for you!*

Turns out I was overcomplicating things a bit. I assumed that something in the .htaccess file was over-riding my VirtualHosts settings in httpd-vhosts.conf: hence the .htaccess modifications.

In a classic bit of carelessness, it turns out I was editing the wrong httpd-vhosts.conf file – there are two in different folders :S

So, the following steps from the first post are still valid:

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

to

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Now, edit httpd-vhosts.conf to include a VirtualHost for your domain, e.g.

#
# Use name-based virtual hosting.
#

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin <you@email.com>
ServerName theflatdomain.com
ServerAlias *.theflatdomain.com theflatdomain.co.uk *.theflatdomain.co.uk
DocumentRoot “www/flatsites/thisflatsite/”
</VirtualHost>

But, not instead of editing the .htaccess file, we just need to make a further entry in the httpd-vhosts.conf file, ABOVE the flat site virtual host(s):

<VirtualHost _default_:80>
DocumentRoot “www/wordpress/”
</VirtualHost>

You can then simply add further VirtualHosts UNDER your default catch-all VirtualHost for each flat site you need to host. This will leave the WordPress installation to deal with any domain names that aren’t explicitly declared as separated flat sites. Note that I’m using Strider’s Virtual Multiblog for WordPress to host lots of different blogs/domains at once.

Sweet 🙂 Leave a comment if this was useful for you?

2 Comments

Comments are closed.