Hosting wordpress in a subdirectory of an existing Rails application

I have an existing rails application at and wanted to include a wordpress blog at I’m using Apache and Passenger.

My <VirutalHost> configuration has the DocumentRoot at /srv/www/ (which is itself a symbolic link to /srv/www/ For ease of maintenance, and to avoid any conflicts between rails and wordpress, I placed wordpress outside of the rails app at /srv/www/

However, I needed to tell Apache to redirect access to the wordpress resources which are not located in the DocumentRoot. The solution? Create an Apache Alias. There’s an excellent descrpition in the Linode Library about Managing Resources with Apache mod_alias.

This got me through the wordpress install with the wp-admin/install.php. Unfortunately, I still couldn’t access my blog. The default rails error page still kept rearing its ugly head. Turns out that’s due to Passenger, which kept directing my non-file-specific traffic to my rails application (e.g., when trying to access or without a specific php file in the URL).

I found the fix for this at WordPress Answers. My final working configuration is below, with the additional fix in bold:

<VirtualHost x.x.x.x:80>
    DocumentRoot /srv/www/
    Options FollowSymLinks

    # an Alias for the wordpress blog
    Alias /blog /srv/www/
    <Directory /srv/www/>
        PassengerEnabled off
        # make the WordPress .htaccess file work
        AllowOverride all
        Order allow,deny
        Allow from all



  1. Nice and very useful 🙂


Leave a Reply

Your email address will not be published / Required fields are marked *