4

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...

7
rewrite    ^(.*)substrtocatch(.*)$    $1changedsubstr$2;
  • Wouldn't return be better to inform SEO and robots of the 301? – Zac Grierson Jul 3 '17 at 21:35
  • 1
    @ZacGrierson It depends on what you want to do; if a 301 is required, just use the permanent flag as per nginx.org/r/rewrite – cnst Jul 5 '17 at 3:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.