I am using Sitecore 10.3 and JSS next app, I need to add language in the home page URL. Ex: https://mydomain.com to https://mydomain.com/en/, also need all URLs to end with /. can I do this from IIS??

  • Next.js doesn't use IIS
    – Richard Seal
    Mar 22 at 19:37

2 Answers 2


You can update middleware.ts as below to redirect to a specific language.

import { NextResponse } from 'next/server';
if (!req.cookies.get('Site_Language')) {
  const resp = NextResponse.redirect(
    new URL(`/${'en'}${req.nextUrl.pathname}${req.nextUrl.search}/`, req.url)
  resp.cookies.set('Site_Language', 'en');
  return resp;
return middleware(req, ev);

In the above code it checks if the cookie for language does not exist, it sets the cookie and does the redirection including trailing slash in the url.

Make sure the language you are redirecting to is not set as default locale inside next.config.js.

Hope this helps!!!


Not sure why you want to end all URLs with /. But just to embed language in the URL, you can use this configuration:

        <add name="localizedProvider">
          <patch:attribute name="lowercaseUrls">true</patch:attribute>
          <patch:attribute name="languageEmbedding">true</patch:attribute> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.