Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

522
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!