首页  >  问答  >  正文

使用Nuxtjs和i18n进行本地化重定向的SPA模式

<p>当我在SPA模式下生成Nuxtjs时(SSR:false),nuxt生成的dist文件夹中没有index.html文件。</p> <p>所以我有两个问题</p> <p><strong>1st:我需要重定向到lang文件夹,例如exmple.com重定向到exmaple.com/{locale}</strong></p> <p><strong>2nd:我需要为子页面重定向,例如exmple.com/admin重定向到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粉071626364P粉071626364393 天前406

全部回复(1)我来回复

  • P粉587970021

    P粉5879700212023-08-29 10:16:25

    我有一个解决这个问题的想法,但我不知道它是否是最好的解决方案。

    只需使用 .htaccess 来处理请求并返回所需的索引。

    回复
    0
  • 取消回复