E
E
Eugene2019-11-11 20:33:05
Nginx
Eugene, 2019-11-11 20:33:05

Nginx redirect setup?

Good afternoon.
It is necessary that when accessing the site my.site.ru/redirect, it would be redirected to the site blog.mysite2.ru
with this setting:

server {
        merge_slashes off;
        location ~* "my.site.ru/redirect/" {
                rewrite ^ $scheme://www.blog.mysite2.ru;
        }
}

I get an error:
2019/11/11 21:29:54 [alert] 9036#9036: *3 open socket #12 left in connection 3
2019/11/11 21:29:54 [alert] 9036#9036: aborting

How to set up a redirect correctly
Unfortunately, /redirect is a prerequisite
if you do it like this
erver {
        listen 80;
        server_name my.site.ru;
        return 302 http://blog.mysite2.ru$request_uri;
}

everything works, but as soon as I do I
my.site.ru/redirect
get an error
server name "my.site.ru/redirect" has suspicious symbols/code>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-11-11
@wesow

config that worked

server {
listen 80;
server_name my.site.ru;
location /redirect {
rewrite ^ $scheme://www.blog.mysite2.ru;
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question