Tuesday 23 May 2017

Wordpress redirect issue on node.js http-proxy

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 /sample/wordpress it redirects me to /wordpress.



via William Valhakis

No comments:

Post a Comment