开发者

Tell Rails to ignore particular URL and let Apache handle

开发者 https://www.devze.com 2023-02-09 12:41 出处:网络
I have a rails app running on my Apache server via Passenger. Occassionally I am using some PHP scripts for the website, and have placed them in the public directory.

I have a rails app running on my Apache server via Passenger.

Occassionally I am using some PHP scripts for the website, and have placed them in the public directory.

When I go to /php/ I want Apache to handle the request with the PHP parser and have rails ignore it.

Currently I can go to /php/index.php and it works fine. However I need /php/ to work as well but rails keeps looking for the controller to handle it.

I have a feeling this is something to do with apache rewrite rules, but I cant figure it out.

I have used

RewriteEngine On 
RewriteRule ^php - [L] 
RewriteBase / 
RewriteCond %{REQUEST_FILENAME} !-f 
Re开发者_如何学GowriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 

in the /php/.htaccess file but this doesnt work. I still get the page not found error by Rails.


I think you can do this in your Passenger app's main Apache config file - something along the lines of this

<Directory "/.../myapp/php">
    PassengerEnabled off
    AllowOverride all
</Directory>

inside your VirtualHost block should do the trick (of turning Rails off, at least - turning PHP on is up to you!).

My answer is based off the ModRails Apache documentation - see section 5.6 for more on the PassengerEnabled command.

0

精彩评论

暂无评论...
验证码 换一张
取 消