Is it a way to use Next.js and WordPress pages under the same domain?

Viewed 627

I have a Next.js site, but for the Landing page I would use a WordPress site. How is it possible?

2 Answers

In the next.config.js, you can set rewrites to work like a proxy with specific application paths. If you want only NextJS homepage router to another domain homepage, you can do this:

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

Docs

Everything depends on the hosting server that you will use for hosting those website's. You can use one domain for both but you might be forced to use different route's.

Example:

Landing Page : www.example.com or www.example.com/home

Wordpress : www.example.com/news

Using apache for hosting, you can define a .htaccess that would redirect to the right application depending on the route. I would suggest you to look into that, unless you can provide us more details about your hosting solution.

Edit: You can check out the vercel configuration file to route something to specific subfolder/files. More info here: https://vercel.com/docs/configuration#project/redirects

Related