0

Unsure why this isn't working.

URL: https://example.com/blog/2009/07/23/example redirect to: https://example.com/example

rewrite "^/blog/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)" /$5 permanent;
3
  • What exactly isn't working? – Michael Hampton Jan 5 '19 at 2:43
  • Sorry, its just not doing anything, its not rewriting the URL – JCats Jan 5 '19 at 2:50
  • Just for some added, using a rewrite like this rewrite "^/([0-9]{4})/([0-9]{2})/(.*)" /$3/ permanent; Works just fine on a URL with just example.com/2000/02/03/example in it – JCats Jan 5 '19 at 3:01
0

Figured it out :)

location /blog {
rewrite "/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)" /$4 permanent;
}

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.