SPA pattern for localized redirection using Nuxtjs and i18n
P粉071626364
P粉071626364 2023-08-28 13:53:37
0
1
436
<p>When I generate Nuxtjs in SPA mode (SSR: false), there is no index.html file in the dist folder generated by nuxt. </p> <p>So I have two questions</p> <p><strong>1st: I need to redirect to lang folder, for example exmple.com redirect to exmaple.com/{locale}</strong></p> <p><strong>2nd: I need to redirect for subpages, for example exmple.com/admin to exmaple.com/{locale}/admin</strong></p> <pre class="brush:php;toolbar:false;">// 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 }, ...</pre></p>
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 .htaccess to 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!