Report this

What is the reason for this report?

How to redirect 301 in nginx?

Posted on April 13, 2018

Hello! I need 301 redirect from http://myweb.com/watch/fadfadf1 to http://myweb.com/watch-1/fadfadf1

Please help me. Thank you very much



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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

rewrite ^/watch/fadfadf1$ http://www.newdomain.com/watch-1/fadfadf1 redirect;

Then restart nginx with:

sudo service nginx restart

Hi, I want rewrite all link watch to watch-1 http://myweb.com/watch/all-link to http://myweb.com/watch-1/all-link

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.