Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

523
Visualizações
Nginx, nuxt.js static generated mode and redirection of trailing slashs

i currently have a problem configuring my Nginx correctly for nuxt.js generated sites. What i want to achieve is the following

/magazin -> /magazin/index.html
/magazin/ -> 301 /magazin

/magazin/artikel/titel-goes-here -> /magazin/artikel/titel-goes-here/index.html
/magazin/artikel/titel-goes-here/ -> 301 /magazin/artikel/titel-goes-here

currently this is the other way around.

If im correct i shouldn't use a proxy pass to a e.g. pm2 instance with express etc. as it destroys the sense of static site generation.

But how can i get this page structure to work, as i need the same url's as our legacy service for SEO reasons, which used Angular Universal SSR

my current config is:

location ^~ /magazin {
   root /path/to/dist;
   index index.html ;
}

if i add something like

rewrite ^(.+)/+$ $1 permanent; 

i get an infinite 301 loop

Thanks for the help

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You cannot use the built in index directive, as it works the other way around (as you have observed).

You can use try_files to test for the existence of the index.html file. Use a named location to process the redirection.

For example:

location ^~ /magazin {
    root /path/to/dist;
    try_files $uri $uri/index.html @rewrite;
}
location @rewrite {
    rewrite ^(.+)/$ $1 permanent;
}

See this document for details.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda