Posts Tagged ‘php’

Peaceful coexistence between Rails and PHP

Tuesday, March 3rd, 2009

Have a Rails application you’d like to have coexist with some existing PHP code? Our website is set up as a Rails app, and we’d like to add bbpress, a php forum application, deployed as a directory. Generally speaking, it works fine – but the DirectoryIndex, in this case index.php, doesn’t get picked up and you are returned the 404 page from your Rails application.

To be sure, make sure you have the DirectoryIndex set up with index.php on the end. DirectoryIndex index.html index.php

now set up mod_rewrite to take care of business
RewriteEngine on

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}/index.php -f 
RewriteRule ^(.*)$ $1/index.php [QSA,L] 

If you’re using Mongrel, make sure you have those rewrite rules in the Apache config file before it the request gets rewritten off to the proxy balancer.

That’s all she wrote.

Subscribe:

Add to Google
RSS
Try ExpanDrive

If you’ve heard of SSH then you need ExpanDrive.