How to redirect 301 in nginx?

Posted April 13, 2018 9.6k views

Hello! I need 301 redirect from to

Please help me. Thank you very much

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Add the following to your server block in your site definition in /etc/nginx/sites-enabled

rewrite ^/watch/fadfadf1$ redirect;

Then restart nginx with:

sudo service nginx restart