Skip to content

How to Remove the Date from a WordPress Post URL

So, you want to remove the date from your WordPress post URLs? I get it. Those /2016/07/09/post-slug URLs that seemed pretty cool when you (or someone else) set it up get old.

The primary reason those date URLs are an issue: when you update that post, what should you do? Leave it’s URL looking old? Move it to the new one and worry the link will break? These concerns are why we use the “Post name” option for WordPress permalinks here at WPShout and encourage most of our clients to do the same.

In this Quick Guide we cover how to change a WordPress permalink structure. The problem: while toggling the setting itself can work, will cause your WordPress site to present 404 errors at your old URLs.

What’s wrong with that? It will tank the SEO of the site you’re working on. If you’re curious what that means, we strongly suggest you read our article on WordPress SEO mistakes before moving further.

How to Rewrite WordPress URLs

The trick we’ll cover here to avoid generating 404s on our site: we’ll do our URL rewrites with .htaccess files.

Here’s a video explaining how I change permalink structure for a WordPress post, and make sure that I forward all the traffic to the old URLs to the new ones:

WordPress URL rewrite with .htaccess: the Code

When I simply remove post dates from URLs, WordPress is confused. It knows my “new” permalink settings, but it immediately forgets the old one. So we have to help it, that’s where this URL rewrite in .htaccess rule comes in: it’ll make sure that WordPress never sees our old permalink structure. Here’s the code, which you’ll typically put in a file called .htaccess which will be at the root of your WordPress site’s file system:

## To change example.com/2019/01/01/post-slug to example.com/post-slug
<IfModule mod_rewrite.c>
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]
</IfModule>

The really important thing about this code: it requires that your WordPress server be running “Apache” not “Nginx,” and that your Apache configuration support .htaccess files for URL rewrites. I mention this because this is the only way to remove the date from a WordPress post URL we’ll cover in this Quick Guide. But if you’re struggling, hopefully that gives you some helpful pointers on where to look next.

Step-by-Step Guide to Remove the Date from a WordPress Post URL

So if you want to change your permalinks to remove post date in WordPress, here’re the steps we recommend you take:

  1. First, you’ll want to change the permalink settings. To do that, navigate to “Settings > Permalinks” in the left bar of the WordPress admin area.
  2. The rest of this tutorial assumes that you’ve chosen URLs like mysite.com/post-slug. If you do want that URL structure for WordPress, select “Post name” (the fifth option as I write this) on the Permalink Settings page. Press “Save Changes.”
  3. Now, to supper WordPress, we’ll do a URL rewrite with htaccess. As mentioned above (don’t worry if you didn’t use it) to change the change permalink structure for WordPress posts, we’ll need to find the .htaccess file. This is most easily done by first connecting to your web host via SFTP. If you’re new to that, here’s a guide.
  4. Once connected, find the .htaccess file at the root of your WordPress installation. Here’s where we’ll put the code to change our permalink structure for WordPress to remove the date.
  5. URL rewriting is doing by .htaccess for *most* WordPress sites. So we’ll open up that file, and paste in these lines:
    ## To change example.com/2019/01/01/post-slug to example.com/post-slug
    <IfModule mod_rewrite.c>
    RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]
    </IfModule>
  6. Save and upload that file back to the server. With that, you should have successfully removed the date from your WordPress post URLs, without triggering a bunch of 404 errors.

Changing permalink structures in WordPress can be daunting, but hopefully we’ve guided you through. 🙂 If this is a new topic to you, we again strongly recommend you read up on SEO mistakes before attempting something like this the first time, as they’re one of the few types of mistakes in WordPress that can be impossible to quickly fix.

“My Developer Ruined My Site’s SEO”: Three Huge SEO Mistakes and How to Avoid Them

David Hayes

14 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Susheel C
July 9, 2023 5:11 pm

This didn’t work for me. It just did nothing at all. Why, I wonder… ?

Johan
May 31, 2021 1:13 am

THX! This also works with LiteSpeed servers. At least it worked for us 🙂

Mica Mesina
January 16, 2021 10:48 am

I am using the free version from wordpress.com and I cannot find the permalink option. Does this only work for those with their own domains or upgraded plans?

Surendra
July 16, 2020 10:20 am

I am trying to do that for my blog but getting 404 error on some posts. Don’t know how to restore that.

esm software
July 15, 2020 4:09 am

Can I anyone let me know about 504 error. I face this error several times I talk to server team but they don’t fix

Neha
September 10, 2019 11:14 pm

Hi, I’m into similar issue but I cannot locate htaccess in my wordpress site. Please suggest as I tried to locate it in SEO -> tools -> file editor. htaccess does not exist at this location.

haseeb
August 29, 2019 7:50 am

its only for apache , can anyone help me as how to use this with Nginix (my blog is launched on AWS cloud so i am using cloudfront and nginix)

Saniul Hassan
May 20, 2019 1:53 am

Hi,

Guide to Remove the Date from a WordPress Post URL

I don’t know this before when search it on google i have found your website at here and read your written article and try to change my self then i have done after apply it on my website.

Thanks a lot for your beautiful article.

Saniul Hassan
May 20, 2019 1:53 am

Hi,

Step-by-Step Guide to Remove the Date from a WordPress Post URL

I don’t know this before when search it on google i have found your website at here and read your written article and try to change my self then i have done after apply it on my website.

Thanks a lot for your beautiful article.

Felicia
March 23, 2019 4:11 pm

1. Do you think you’ll ever write advice for those of us who have an nginx-based managed Word Press server like Liquid Web (whom you recommend)?

2. I have over 3000 posts on my site going back to 2012. All were crested using the date/slug format. I have a plug in by Yeost that will create a redirect for individual posts on which I change the URL, but it doesn’t support bulk changes. And WP tells me(as I understand it) that changing my URL settings is retroactive, therefore would cause 404 errors on every past post. Is there a solution you know of that could handle creating redirects for all of my posts in one fell swoop? As above, it would have to be usable on an nginx server. Maybe this could be a subject for a future post?

Fred Meyer
March 27, 2019 10:51 am
Reply to  Felicia

Hi Felicia,

Great questions! We don’t know a ton about writing nginx rules ourselves, so our solution on nginx-based hosting environments (e.g. WP Engine uses nginx reverse proxy) has been to get a tech support person on the line, explain exactly what we’re looking for, and not hang up the phone until the resulting redirects work properly . Have you tried that? 🙂

Sefa Tsegha
March 21, 2019 11:16 am

Thank you for this tutorial.

I tried changing my permalinks before, the result was not good. I had so many 404 errors but I couldn’t figure out what was wrong. However, I have just done it again following your guidance, and it as worked well.

Thanks for the .htaccess code.

MahMoud AsFour
March 19, 2019 2:35 pm

when i change the permalink settings only the date disappear from a post link without edit “htaccess” file
why this ?

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!

Most Searched Articles

Best JavaScript Libraries and Frameworks: Try These 14 in 2024

In this post, we look at the best JavaScript libraries and frameworks to try out this year. Why? Well, with JavaScript being available in every web browser, this makes it the most accessible programming language of ...

25 Best Free WordPress Themes (Responsive, Mobile-Ready, Beautiful)

If you're looking for only the best free WordPress themes in the market for this year, then you're in the right place. We have more than enough such themes for you right ...

12 Best WordPress Hosting Providers of 2024 Compared and Tested

Looking for the best WordPress hosting that you can actually afford? We did the testing for you. Here are 10+ best hosts on the market ...

Handpicked Articles

How to Make a WordPress Website: Ultimate Guide for All Users – Beginners, Intermediate, Advanced

Many people wonder how to make a WordPress website. They’ve heard about WordPress, its incredible popularity, excellent features and designs, and now they want to join the pack and build a WordPress website of their own. So, where does one get ...

How to Start an Ecommerce Business: Ultimate Guide for 2024

Is this going to be the year you learn how to start an eCommerce business from scratch? You’re certainly in the right place! This guide will give you a roadmap to getting from 0 to a fully functional eCommerce business. ...