Running Node.js behind Apache, .htaccess configuration together with PHP
<p>I'm working on a project where website content is based on PHP(CodeIgniter) behind Apache server, and my duty is to write a node.js as an API to upcoming mobile version of the app.
(Note, our hosting is managed, we do not have access to virtualhost so using proxypass is out of reach)</p>

<p>I have to make my node file run behind Apache, in a URL like "domainname/api".
When said URL is called, Apache has to bridge this request to localhost:port, where node is living on.</p>

<p>Here is my node.js file:</p>

<pre><code>var fs = require('fs');
var http = require('http');
var app = require('express')();
var options = {
};

app.get('/', function (req, res) {
       res.send('Hello World!');
});

http.createServer( app).listen(61000, function () {
       console.log('Started!');
});
</code></pre>

<p>Here is my .htaccess file:</p>

<pre><code>RewriteEngine on 
RewriteRule ^$ /index.php [L] 
RewriteCond %{HTTP_HOST} !^ourdomainname\.com
RewriteRule (.*) http://ourdomainname.com/$1 [R=301,L]
RewriteCond $1 !^(index\.php|info.php|resource|system|user_guide|bootstrap|robots\.txt|favicon\.ico|google&lt;somevalues&gt;.html) 
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteRule ^/api$ http://127.0.0.1:61000/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/api/(.*)$ http://127.0.0.1:61000/$1 [P,L]
</code></pre>

<p>Although node works locally(on our managed hosting server) (I can call "lynx localhost:61000/" and see proper output), it doesn't work on outside local. All our calls to "ourdomainname.com:61000/api" is sent to CodeIgniter(PHP), not to our node.js file.</p>

<p>Any help is appreciated.</p>