Next.js Discord

Discord Forum

how to make non-english urls to work in next.js

Unanswered
Exotic Shorthair posted this in #help-forum
Open in Discord
Exotic ShorthairOP
.

10 Replies

@Exotic Shorthair .
just rename the folder in the non-english word. Like that it'll work
Exotic ShorthairOP
@B33fb0n3 @American black bear
The user enters this URL as shown in the image, which contains Arabic words. But under the hood the browser encodes all non-English words, so the real request that nextjs receives is for /%D8%A7%D9%84%D8%AD%D9%85%D9%84
---
@Exotic Shorthair I would never recommend you to use non-English in your url
what's the reason if I am allowed to ask?
Exotic ShorthairOP
the only solution that I can find right now is that renaming the folder in app directory to %D8%A7%D9%84%D8%AD%D9%85%D9%84 or using rewrites in next.config
/** @type {import('next').NextConfig} */
const nextConfig = {
  async rewrites() {
    return [
      {
        source: "/%D8%A7%D9%84%D8%AD%D9%85%D9%84",
        destination: "/pregnancy"و
      },
    ];
  },
};

export default nextConfig;
@James4u isn't this better for SEO?, snice all of my blog's readers understand Arabic
as far as I know, yeah url also has some impacts on SEO but mostly the content (if I compare content vs url)
anyway I felt this kind of redirection looks silly