B
B
BoneFletcher2015-10-28 14:08:54
Nginx
BoneFletcher, 2015-10-28 14:08:54

How to make a correct redirect to nginx?

There is the following file structure:
mysite.com/pages/en.html
mysite.com/pages/ru.html
How can I make these pages appear when accessing the URL:
mysite.com/en/
mysite.com/ru/
?
But at the same time, the old paths should be inaccessible
mysite.com/pages/en.html - 404 Not found
Standard config:
location / {
try_files $uri $uri/ =404;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nirvimel, 2015-10-28
@BoneFletcher

location / {
   rewrite ^/(\w+)/$ /pages/$1.html break;
   return 404;
}

I wrote it right on my knee. Didn't check, of course.
But the idea itself, I hope, will be clear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question