iBlognet

How to Remove Post Date From WordPress Permalinks

by Editor

Remove Post Date From WordPress Permalinks WordPress allows bloggers to set custom permalink structure by adding post dates in the permalinks making it look more organized in nature. The main advantage of using dates in the permalink is that it provides immediate information about the article freshness, when was it published. Also it creates a better hierarchy of articles, if you want to search for specific post.

But putting dates in permalinks has very few benefits and personally I didn’t liked the idea of adding dates in permalinks until I switched from Blogger to WordPress. I maintained the same permalinks as it was previously on Blogger as I was unaware of WordPress SEO. So after researching some pros and cons about permalinks structure’s I found there are two best permalink structure.

1. domain.tld/%postname%.html

2. domain.tld/category/%postname%.html

And I decided to go with the first one, because the URL looks much clean, short and sweet. So the first thing was to change the permalink structure in the WordPress settings section, so all my future post will be posted in new permalink structure.

Step 1 – Changing permalink structure

Go to Settings > Permalinks > and add the following custom permalink format and save the changes.

/%postname%.html

Permalink Settings

Wait! That’s not all! If you have previously published article with dates base permalinks, it would result in a 404 page from search engines and other social networking sites where you’ve submitted the post. So a simple solution to this would be to add a 301 redirect via htaccess.

Step 2 – Adding 301 Redirect via .htaccess

Login to your web server account via FTP and search for .htaccess file in the ” root directory ” of the domain.

Download the file locally on your computer and edit it with Notepad or Notepad++. You can add redirect using mod rewrite or mod alias rule. Use any one.


Using MOD REWRITE RULE

Remove Existing Permalink Format Add
Year/Month/Day /%year%/%monthnum%/%day%/%postname%.html RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?$ http://domain.tld/$4/ [R=301,L]
Year/Month /%year%/%monthnum%/%postname%/.html RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)/?$ http://domain.tld/$3/ [R=301,L]
Year /%year%/%postname%/.html RewriteRule ^([0-9]{4})/([^/]+)/?$ http://domain.tld/$2/ [R=301,L]

Change domain.tld with your domain name. See the image below. You should add the code in the mod_rewrite.c module.

Remove Permalink Via htaccess

 


Using MOD ALIAS RULE

Remove Existing Permalink Format Add
Year/Month/Day /%year%/%monthnum%/%day%/%postname%.html RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://domain.tld/$4
Year/Month /%year%/%monthnum%/%postname%/.html RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://domain.tld/$3
Year /%year%/%postname%/.html RedirectMatch 301 ^/([0-9]{4})/([^/]+)/$ http://domain.tld/$2

Change domain.tld with your domain name. See the image below. You should add the code in the mod_alias.c module.

Remove Permalink Via htaccess1

Save the .htaccess file and replace it on your server. Check if the redirect is working by clicking few old URL’s structures. You can find them on search engines or social networking sites. That’s it, you’re done, redirecting old URL structure without any plugin! Thanks to Joost de Valk for creating redirect generator. Image Credits: Caro’s Lines

ug8vsywtk3t

Article by »


Admin and Editor of iBlognet iBlognet has written 294 fantastic article(s) on iBlognet.


Author Connect »

1 KBharath

Thank you for sharing this clean tutorial on removing the dates in wordpress permalinks.

2 Danilo

Great tutorial, it’s really useful! thanks

3 Charles

Thanks for the post. Removing dates from you posts sometimes is very important, most especially, the new bloggers. I have some blogs, most of them have the date setting while others do have it. Thanks again

4 Kashish

I have a blog and have been running it past one year with ‘year’ in the permalinks. Now I want to remove ‘year’ from the permalinks but doings removes all the google +1’s and fb likes on individual posts. As these are important with panda updates I want to keep them.
So is there any solution to it ?

5 Sahil Umatia

Sorry for the late reply. Don’t know, but your comment was marked as spam. Anyways, no you cannot keep those G+1’s and fb likes on individual post. But your post are still available on those networking sites. And there’s no need to worry, until they are not resulting in any 404 page and you have set proper redirection on your blog URL’s.

6 Hector Torres

Thanks for this post about the rewrite rule after changing WP permalinks. It came in very handy.

One quick suggestion to help your readers: when they copy the code from the table (see example below), they will get an unnecessary space between “http://” and “domain.tld” and between “domain.tld” and “/$4”. This could be confusing to some novice readers 🙂

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http:// domain.tld /$4

Thank again!

7 Sahil Umatia

Thanks for the tip Hector! I have updated the post.

8 Toufiq

i am using NGinx, any help?

Comments on this entry are closed.

Previous post:

Next post: