question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to redirect the index / after setting noPrefixDefaultLocale

See original GitHub issue

Hello, i have problem:

  1. i set noPrefixDefaultLocale to false in the description: By default, paths generated for the default language don’t contain a locale prefix, set this option to false to disable this behavior

  2. so the generated routes like this, good:

[
  {
    path: "/en/",
    component: _3237362a,
    name: "index-en"
  },
  {
    path: "/fr/",
    component: _3237362a,
    name: "index-fr"
  }
]
  1. then when starting the app, do not redirect to index it shows 404 page not found error!!! http://localhost:port/ -> error http://localhost:port/en -> index page with English

  2. what i want is some setting that change the default language after setting noPrefixDefaultLocale: false or add another auto generated route like this of the default language:

[
  {
    path: "/",
    component: _3237362a,
    name: "index-en" // the default language!!! or redirectRootToLocale content!!
  },
  {
    path: "/en/",
    component: _3237362a,
    name: "index-en"
  },
  {
    path: "/fr/",
    component: _3237362a,
    name: "index-fr"
  }
]
  1. i think this : redirectRootToLocale: 'en' must work every time. the problem as description said: Specify a locale to which the user should be redirected when visiting root URL (/), doesn’t do anything if noPrefixDefaultLocale is enabled

so make redirectRootToLocale work every time to solve this as i think!!

and thank you 😃.

<div align="right">This question is available on Nuxt.js community (#c23)</div>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:9

github_iconTop GitHub Comments

1reaction
MitsuhaKitsunecommented, Mar 22, 2018

I have more things to make nuxt better, but I think this should implemented on nuxt core instead i18n, actually nuxt have a duplicated content problem on his routes too, for example:

/news/ and /news both are valid and the same route, but for SEO it’s a big problem, should be more strict and generate only one mode, for example if it’s a folder generate only a /foldername/ and don’t allow access without final slash /foldername (instead access make a 301 redirection to /foldername/ or show 404, both are valid for SEO) and for single vue files make only the /filename as valid without the final slash.

I gona try to learn about modules and try to send PR to you and nuxt to help with this things, I read the documentation on https://nuxtjs.org/api/configuration-modules but I still don’t know how I can debug the module startup, I tried to put some console.log('test') but don’t show anything on console.

1reaction
paulgvcommented, Mar 22, 2018

Thanks @MitsuhaKitsune, I like your approach and I’ll implement it asap 😃 I’m planning on refactoring the module’s code sometime to make it more scalable but I’m kinda waiting on Nuxt 2.0 to be released as it will bring better support for ES6 which should facilitate modules’ development.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to redirect the index / after setting noPrefixDefaultLocale
Hello, i have problem: i set noPrefixDefaultLocale to false in the description: By default, paths generated for the default language don't ...
Read more >
ruby on rails - redirect to index rather than show after save
while with a redirect the index function of the controller will run and then the view will be rendered from there. you are...
Read more >
How can I redirect and rewrite my URLs with an .htaccess file?
Redirecting non-existing pages to index.​​ If your index page isn't index. php, just change the last line to your actual index file.
Read more >
How to Redirect a Web Page in HTML - W3docs
The simplest way to redirect to another URL is to use an HTML <meta> tag with the http-equiv parameter set to “refresh”. The...
Read more >
How to Code a PHP Redirect - Bluehost.com
To setup, a simple redirect simply creates an index.php file in the directory you wish to redirect from with the following content:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found