I just finished deploying a Rails application onto a subdomain of a site that has WordPress installed on the root domain. Unfortunately, WordPress’ htaccess rules made it a little bit more difficult to launch than expected.

Here’s what I did to get Rails and WordPress to play nicely together:

First, I uploaded the Rails app into it’s own directory (assume the application is called my_app):


After creating the subdomain, I created a symbolic link from within the public_html directory of the WordPress installation to the Rails application’s public directory:

ln -s ~/app/my_app/public ~/public_html/my_app

Finally, I added the following two rules to the htaccess file:

RewriteCond %{REQUEST_URI} !^/my_app.*
RewriteCond %{SERVER_NAME} !my_app.domain.com

The final htaccess file looks like this:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

RewriteCond %{REQUEST_URI} !^/my_app.*
RewriteCond %{SERVER_NAME} !my_app.domain.com

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Note that if you update the permalinks within WordPress, then this file will be overwritten and you’ll need to correct the changes.


Join the conversation! 8 Comments

  1. nice tips, and def make a .bak of the .htaccess!

  2. notice he said “looks hot” not “coded beautifully” …. :-)

  3. When I originally commented I seem to have clicked on the -Notify me when new comments are added- checkbox and now whenever a comment
    is added I receive 4 emails with the same comment.

    Perhaps there is an easy method you are able to remove me from that service?


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.