| February 08, 2010 by |
Have you ever wanted to run a PHP application inside of a Rails application? Here's a scenario: your website is written in ruby on rails. You want to run a php application, like Magento inside it, under a directory called shop. Since all web-accessible files in Rails are located in the public directory, your shop directory will be located in public/shop. However, whenever you try to access this directory by going to http://www.yourwebsite.com/shop, You get a 500 error from your Rails application saying: Application error Rails application failed to start properly, or something along those lines.
This is because rails thinks that this subdirectory is a controller or an action within your rails application that isn't acting properly, when in reality, it's a real subdirectory with PHP files inside! We need to convince it otherwise. The easiest way to do this is by creating an .htaccess file inside the shop directory. Then paste this code into the .htaccess file:
RewriteEngine On
RewriteRule ^([^\.]+[^/])$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_URI} !^/-
RewriteCond %{DOCUMENT_ROOT}/-%2 -d
RewriteRule ^(.*)$ -%2/$1 [QSA,L]
That's it! Try it again, and your PHP code should run without a problem!

trying
hi,
this doesn't seem to work for me