Here is an example of the URL's we will be rewriting

From: https://bigscoots.com/2017/04/09/sample-post/
To: https://bigscoots.com/sample-post/

We will be using an Nginx location to perform the rewrite

location ~ "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/([a-zA-Z0-9_.-]+)/$" {
     rewrite ^(.*)/(.*)/(.*)/(.*)/ /$4/ permanent;
 }

You will want to enter this in above your location / {

Example:

location ~ "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/([a-zA-Z0-9_.-]+)/$" {
     rewrite ^(.*)/(.*)/(.*)/(.*)/ /$4/ permanent;
 }

location / {
   # Wordpress Permalinks
  try_files $uri $uri/ /index.php?q=$uri&$args;
 }
Did this answer your question?