Suresh Kumar S
Suresh Kumar S

Reputation: 182

Can I use WordPress blog as a subfolder of my main domain?

I am developing an MEAN stack application and I have a WordPress blog for our website as well. I would like to integrate WordPress blog as part of the webapp in main domain like www.example.com/blog instead of blog.example.com.

How can I configure the WordPress blog as part of the Angular node application.

Upvotes: 3

Views: 2062

Answers (3)

Sumit Sinha
Sumit Sinha

Reputation: 666

For something to be accessible at HOST/url. It doesn't necessarily has to be a subfolder. It can reside anywhere in your system as far as it is accessible from your web server application.

Here, if you are using a web-server program like Nginx or Apache web server you can add a config in that to send any request pointing to /url (say /blog in your case) to the folder where your wordpress blog is located. Like (for nginx):

location /blog {
    index index.php;
    root /var/www/blog/public;
}

If you are not using nginx or apache over node.js i.e. node.js is directly listening to the external port then you can use node-php to create a route at /blog and place wordpress folder at the respective path.

var express = require('express');
var php = require("node-php"); 
var path = require("path"); 

var app = express();

app.use("/", php.cgi("/path/to/wordpress")); 

app.listen(9090);

If wordpress is on another server then you can proxy pass all requests to /blog to that server. Like (for nginx):

server {
  listen 80;
  server_name mydomain.com;
    location /blog {
      proxy_pass http://second_instance_internal_ip:80;
      proxy_set_header Host $host;
    }
    location / {
      proxy_pass http://this_instance_ip_for_node.js_app:9000;
      proxy_set_header Host $host;
    }
}

Upvotes: 5

Mark B
Mark B

Reputation: 200617

Create a CloudFront distribution with two origin servers (your nodeJS server and your wordpress server). Configure it to serve the wordpress content at /blog.

Upvotes: 0

Edward Smith
Edward Smith

Reputation: 552

I think a lot of people have been using this WP JSON API

If you are using AWS you could create a WP instance and in your angular application have a service that calls the API and renders the blog posts inside angular

Upvotes: 0

Related Questions