#Rewrites not working for root path (index.tsx)

2 messages · Page 1 of 1 (latest)

sweet pike
#

I want to rewrite all requests to admin.domain.com to domain.com/admin.
All paths works (ex: admin.domain.com/test rewrites to domain.com/admin) except the root path (admin.domain.com is not rewritten to domain.com/admin). How can I do that?

I have this next.config.js:

const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  i18n: {
    locales: ['en', 'sv'],
    defaultLocale: 'en',
  },
  async rewrites() {
    return [
      {
        source: '/:path*',
        has: [
          {
            type: 'host',
            value: '^admin.*',
          },
        ],
        destination: `/admin/:path*`,
      },
    ]
  },
}
#

Rewrites not working for root path (index.tsx)