Ask For Nginx Rewrite URL Condition

Please help me with url rewriting on nginx.
I have a wordpress site with some example of urls structure like this:

Then I decided to change permalink structure from /%post_id%/%postname%/ to /%postname%.html.

So at this point, url permalink structure of my wordpress is:

Currently I’ve made a nginx rewrite rules:

rewrite ^/[0-9]+/(.*)$1 permanent;

This url rewrite only works if user entered url by adding .html manually to end of the url.

But what I want is nginx automatically redirecting if user entered or clicking url: **OR** **OR** 

Redirect to 

Can someone help me with nginx rewriting rules like that?

Source: wordpress

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.