D
D
dealershowers2015-04-14 14:04:38
Nginx
dealershowers, 2015-04-14 14:04:38

nginx url rewrite how?

good afternoon, I use Nginx + php-fpm for bitrix,
there was a question about changing the yurl ...
there is an old link
http://test.com/zapchasti/ there are a lot of links here,
for example test.com/zapchasti/motor
how to convert to
test.com/ motor
construct like
if ( $request_uri ^/zapchasti/$) { rewrite ^/zapchasti/$ /$1? last;} does not work, poke your nose please

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dealershowers, 2015-04-14
@dealershowers

if ( $request_uri ~ "^/zapchasti") {rewrite ^/zapchasti/(.*)$ test.com/$1 permanent;}
worked like this

K
kompi, 2015-04-14
@kompi

The only point is, it's better not to use if.

location ~* ^/zapchasti/(.*)$ {
      return 301 http://test.com/$1;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question