首頁  >  問答  >  主體

使用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 天前405

全部回覆(1)我來回復

  • P粉587970021

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

    我有一個解決這個問題的想法,但我不知道它是否是最好的解決方案。

    只需使用 .htaccess 來處理請求並傳回所需的索引。

    回覆
    0
  • 取消回覆