I've got a Node.js-Server:
app.use(express.static(__dirname + '/public'));
The Problem: When I want to execute a php-file like this:
var xhttp= new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(xhttp.readyState==4 && xhttp.status==200){
var text = xhttp.responseText;
console.log(text);
}
}
xhttp.open("GET","php/gethighscore.php",true);
xhttp.send();
I'll get the code from the php-file as response:
<?php
echo "test";
?>
I know that Node.js send me the static file but I don't know how to avoid that.
I already tried with the .htaccess-file:
RewriteEngine On
#Redirecting the php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.php)$ my-webhost.com/public/php/ [L]
#Redirecting for node
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://localhost:64332/$1 [P]
But it doesn't work.
When I go to my-webhost.com/public/php/gethighscore.php
I get the executed php-script. When I go to my-webhost.com/public/
I'll can use my application without node.js and the php-script is working fine.
I hope you can help me. :)