'How to configure wordpress in a subdirectory of a domain while main directory contain a nextjs project?(EC2, Ubuntu20, Nginx server)

I developed a Nextjs project (say www.example.com) hosted on EC2 Ubuntu20 with Nginx server. Now I want the BLOG part to implement in wordpress in a subdirectory (say www.example.com/blog). I need help in configuration part of Ubuntu and Nginx. Also, need to know in which folder I should install the wordpress package.



Solution 1:[1]

Yes you can do this by using rewrites in the next.config.js

module.exports = {
  rewrites() {
    return [
      {
        source: "/",
        destination: "http://mywordpresssite.com/",
      },
    ];
  },
};

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremiah