M
M
margon802017-10-27 12:52:50
JavaScript
margon80, 2017-10-27 12:52:50

How to implement negate redirect in nginx?

There is a set of URLs with the following content:
/category/*.html
/category/*/XXX.html , where * is a certain alphabetic sequence, and XXX is a number from 1 to 9999
Please tell me how to correctly write a rewrite rule in nginx so that all URLs of the form /category/*.html except for URLs like /category/*/XXX.html were redirected to URLs /category/*/

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
hzzzzl, 2019-07-30
@Benzy

:D
here is the script
colbacolorbar.ru/themes/colba/assets/js/fluidWave.js I
don’t understand at all what’s going on there, like javascript, but some kind of complicated webGL framework, probably
UPD, I found this on github, xs maybe this original code
https://gist.github.com/peretc001/1444c3df210cc66c...

L
Lynn "Coffee Man", 2017-10-27
@margon80

For example like this:

location /category/ {
    # если URI заканчивается на XXX.html,
    # то реврайтим в то же самое и прекращаем обработку.
    rewrite "^(.+\d{1,4}\.html)$" $1 break;
    # у всего остального заменяем `.html` на `/`
    rewrite "^(.+)\.html$" $1/;
}

{1,4} can be replaced with + if the number of digits is not important.

B
Boris Korobkov, 2017-10-27
@BorisKorobkov

all URLs like /category/*.html except URLs like /category/*/XXX.html

PS
in a letter sequence, in addition to letters, slashes, dashes and numbers can occur

Then /category/*.html will be no different from /category/*/XXX.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question