Redirect of permalinks in Wordpress.

hpernaf nginx-forum at
Sun Oct 29 01:49:12 UTC 2017

Hi everyone!

I'm using NGINX with Worpdress on my site and would like to do some 301

My site currently has permalinks:
and would like to switch to

But I already have more than 120 articles published and ranked by Google and
would not like to lose this ranking.

I would like to know how to redirect these links without having to do one by

I did a search and found a website that says that you need to enter the
following lines:

location ~ "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$" {  
 rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$"$4

My question is: Is this code correct? Where should I enter these lines?
I tried inserting into my nginx.conf file and then tried putting it in
.htaccess. But I was not successful, because redirection is not being done
after changing the permalinks.

If anyone can help me, I will be very grateful.

Posted at Nginx Forum:,277107,277107#msg-277107

More information about the nginx mailing list