I am running XAMPP on Windows to host an Apache server on port 80. Now I\'m trying to have a NodeJS script running in the background but the problem is that it can only list
This is same scenario as using NodeJs in a Shared Hosting. I have written a blogpost about it here
Let me give an excerpt.
Just run the NodeJS server at let's say
8080
port.Now, let's say your Apache serves at http://example.com, create a folder in your
public_html
orwww
. let's say the name isserver
. So, your new folder path is http://example.com/server- create a
.htaccess
file in the server folderadd the following lines,
RewriteEngine On RewriteRule ^$ http://127.0.0.1:8080/ [P,L] #which is your node server ip:port RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ http://127.0.0.1:8080/$1 [P,L] #same ip:port
This will redirect all the requests from http://example.com/server
to your Node server.