Nginx url rewrite with string substitution

nginxrewrite

I need to catch if my urls contain a small substr, keep the url as it is and rewrite only that small part, how can I accomplish this?

For example:

http://foobar.com/foo-bar-substrtocatch-baz 

should become

http://foobar.com/foo-bar-changedsubstr-baz

Thanks in advance…

Best Answer

rewrite    ^(.*)substrtocatch(.*)$    $1changedsubstr$2;
Related Topic