Skip to main content
All CollectionsAdvanced CMS SupportWordPress
NGINX location rewrite for WordPress permalinks from Day and name to Post name
NGINX location rewrite for WordPress permalinks from Day and name to Post name

This guide will provide you with the rewrite used in Nginx to rewrite all WordPress Permalinks from Day and name to Post name

Justin Catello avatar
Written by Justin Catello
Updated over a week ago

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

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?