Node Server: http://192.168.0.2:2000

PHP Server: http://192.168.0.2:2001

./public/wordpress/wp-config.js

define('WP_HOME','http://192.168.0.2:2000/sample/wordpress');
define('WP_SITEURL','http://192.168.0.2:2000/sample/wordpress');

./server.js

// SERVER IP: 192.168.0.2
var spawn = require('child_process').spawn;
var http = require('http');
var httpProxy = require('http-proxy');
var express = require('express');
var proxy = httpProxy.createProxyServer();

spawn('php', ['-S', '192.168.0.2:2001', '-t', 'public'], {
   stdio: 'inherit',
   cwd: __dirname
});

var app = express();

app.use('/sample', function(req, res, next) {
   proxy.web(req, res, { target: 'http://192.168.0.2:2001' });
});

var server = http.createServer(app);

server.listen(2000, '192.168.0.2');

Problem

When I go to http://192.168.0.2:2000/sample/wordpress it redirects me to http://192.168.0.2:2000/wordpress.

Read more here: WordPress redirect issue on node.js http-proxy


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: