SPA pattern for localized redirection using Nuxtjs and i18n
P粉071626364
P粉071626364 2023-08-28 13:53:37
0
1
390

When I generate Nuxtjs in SPA mode (SSR: false), there is no index.html file in the dist folder generated by nuxt.

So I have two questions

1st: I need to redirect to lang folder, for example exmple.com redirect to exmaple.com/{locale}

2nd: I need to redirect for subpages, for example exmple.com/admin to exmaple.com/{locale}/admin

// nuxt.config.js ... i18n: { lazy: true, langDir: 'lang/', locales: [ { code: 'en', iso: 'en-US', file: 'en.js', name: 'English' }, { code: 'ar', iso: 'ar-EG', file: 'ar.js', name: 'عربى' } ], defaultLocale: { locale: 'en', prefix: true }, ...

P粉071626364
P粉071626364

reply all (1)
P粉587970021

I have an idea to solve this problem, but I don't know if it is the best solution.

Just use.htaccessto handle the request and return the desired index.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!