Topic: Using Net:HTTP to call a PHP file on the same server?

This may be a bad way of doing this but it worked fine in a shared host environment, but fails in our new dedicated virtual environment...

Basically we need to access an old PHP script that we don't have the time to rewrite in ruby at the moment - It generates an image based on parameter passed in via POST (though we could use get I suppose).

Basically we call the php script which saves an image file to the local file system and returns the name of the image that we then return and display via ajax.

  response = Net::HTTP.post_form(URI.parse('http://mydomain.com/php/draw_add.php'), 
                                { 'var1' => params[:var1], #etc.. lots of variables here})

This used to work fine, but now we get a 400 error as follows:
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /php/draw_add.php was not found on this server.</p>

The files in the php folder are accessible directly from the browser though...

We have the following rule in our vhost configuration file:
RewriteCond %{DOCUMENT_ROOT}/php/%{REQUEST_FILENAME} \.php
RewriteRule ^(.*)$ $1 [QSA,L]

When we look in the directory where the file should be saved there obviously nothing there...

Any thoughts?

Re: Using Net:HTTP to call a PHP file on the same server?

or is there a better way to do this?

Re: Using Net:HTTP to call a PHP file on the same server?

Does this PHP script still work in your web browser? If not, it's not a Rails issue.

Re: Using Net:HTTP to call a PHP file on the same server?

Yeah the script still works in the web browser which is what was so confusing...

I found the problem this evening. It had to do with making the call to
http://mydomain.com/php/draw_add.php
instead of
http://www.mydomain.com/php/draw_add.php

We run some of our surveys off of domains without 'www' enabled in plesk, but our main site we have 'www' enabled. Apparently when this is enabled the server requires the call to be made with 'www' in the string.

Not sure as to the why, but it works...
If anyone can explain, please do! smile