How to safely remove date from URL & redirect it (WordPress)

WordPress uses a permalink system to build URL slug of the posts. To control it users can simply change the settings from the permalink settings from admin panel of the WordPress.

How to remove date from the WordPress Post URLs

  • Simply Login to WordPress as an administrator user.
  • Open up the Settings -> Permalinks page.
  • From various options, choose the ‘Post name‘ option.

Things to know before you change the Permalink

If this is a brand new website without any content then its okay to change this without any further action, but if there are lots of existing posts then you should consider following points before changing the permalink.

  • It will show a page not found (404) error for the old URL.
  • It can effect the search engine ranking.

Now if you have a few posts you can redirect them with simple method or using a plugin manually. But if there are hundreds of posts then redirecting each post manually is not possible. But good thing is that there is method to redirect all the posts at once with a single line of code using the Regex and .htaccess.

How to Redirect URL from date to Without date

These issues can be solved by redirecting with a 301 redirection (permanent redirect) from old URL to the new URL. So here are the methods to redirect the permalink with date to without date.

Manual 301 redirection from ‘URL with date’ to ‘URL without date’ using .htaccess

Before URL :

After :

In .htacess file add this line.

With year / month / date in the URL.

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/]+)/$$4


If only year / month

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$$3

Note: Above code will only work for Apache (mode_rewrite is not required as it uses mode_alias method). If you are using a nginx then consider using a plugin.

Redirect using a WordPress plugin

Best plugin to do this is the redirection plugin. Download and install the plugin and then enter the following details in source and target.

With year / month / date in the URL.

Source: /(\d)/(\d)/(\d)/([A-Za-z0-9-])
Target: /$4

If only year / month

Source: /(\d*)/(\d*)/([A-Za-z0-9-*])
Target: /$3

1 Comment
  1. Terrific work! This is the type of information that are supposed to be shared around the net. Britta Uriel Viccora

Leave a reply

Shopping cart