Skip to content


Apache, WordPress, Passenger, and You

I was trying to get a web application running here along side WordPress, but, in essence, Apache wasn’t letting mod_rails handle the request.

Several Google searches turned up precisely zero answers. After poking around I found the .htaccess file that WordPress so kindly generates for you:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

What this little guy is doing is displaying a nice pretty 404 page, instead of a plain old ugly Apache page. It does this by looking to see if there is a file or directory matching the file name in the request.

Obviously, there aren’t files and directories to correspond with your web app urls. The solution is, quite simply, to tell Apache not to go looking for files and directories when the request needs to go to your web application. So how do you that? Like this:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/myrailsapp.*
RewriteRule . /index.php [L]

Voila! Now Apache won’t try looking for any files or directories when the request begins with “myrailsapp.”

Posted in Apache, Rails, Tips and Tricks.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.