How to implement "NextJs Redirects" with next static site export

121 Views Asked by At

I am using next build && next export to build out directory and uploading it to hostinger (shared server) to deploy the static website. For the seo purpose I want to redirect non-www and http urls to https://www.my-website.com

How will I do that?

https://nextjs.org/docs/api-reference/next.config.js/redirects

async redirects() {
    return [
      {
        source: '/:path*',
        has: [{ type: 'host', value: 'songire.com' }],
        destination: 'https://www.my-website.com/:path*',
        permanent: true,
      },
    ];
  },

I tried to add this config in next.config.js. But it seems to working only with server side and not with static export!

0

There are 0 best solutions below