Spring Sale! Save 30% on all books w/ code: PLANET24
Web Dev + WordPress + Security

Permalink Evolution: Customize and Optimize Your Dated WordPress Permalinks

How to streamline and maximize the effectiveness of your WordPress URLs by using htaccess to remove extraneous post-date information: years, months, and days..

Recently, there has been much discussion about whether or not to remove the post-date information from WordPress permalinks1. Way back during the WordPress 1.2/1.5 days, URL post-date inclusion had become very popular, in part due to reports of potential conflicts with post-name-only permalinks. Throw in the inevitable “monkey-see, monkey-do” mentality typical of many bloggers, and suddenly an entire wave of WordPressers had adopted the following permalink structure:

/%year%/%monthnum%/%day%/%postname%/

The benefits of using this format are primarily organizational in nature. Post-date information that is “built-in” to every URL provides immediate, “at-a-glance” knowledge of post “freshness”. Looking ahead ten, twenty or even a hundred years into the future of the blogosphere, there will be trillions of posts and articles, each with their own unique URL. Archived copies of content may or may not include creation date: dynamically archived pages require deliberate database queries, while those archived statically may no longer have access to post-date data. Including post dates in permalinks provides permanent, facilitative record of content origination. Needless to say, most adopters of dated permalinks probably jump on board because the WordPress Admin makes it super-easy to follow the crowd.

Permalink Evolution

Over time, however, as understanding of search engine optimization permeated the blogosphere, many people who had embraced such “dated URLs” began rethinking their approach to permalinks. Eventually, the trend had reversed, as SEO-savvy bloggers avoided dated permalinks like spider pig. These days, a majority of bloggers initialize their permalinks with either a “category/name” or even a name-only URL format:

/%category%/%postname%/

(or)

/%postname%/

Of course, the benefits to this simplified structure are largely utilitarian in nature. Removal of post-date information effectively reduces the length of permalinks. Shorter permalinks provide greater usability for both humans and machines: people may find such URLs easier to read, while search engines may interpret the permalink as containing a more concentrated array of keywords. Further, search engines such as Google often display a limited number of characters in their search results. Elimination of expendable characters from your URLs results in more (if not all) of your actual post title being displayed to people as they scan the search results. Finally, shorter permalinks are simply easier to work with. They are easier to share, require (slightly) less bandwidth, and look considerably cleaner.

So, as we make our way into 2008, it appears that it is time to evolve our permalinks toward cleaner, shorter, more concise formats, with redundant information such as “year/month/day” either entirely omitted or dutifully removed. If you are setting up a new WordPress-powered site, and have not yet decided on a permalink structure, I would highly advise against inclusion of date information. Likewise, if you are running an established site that has been using dated permalinks for any length of time, you may want to join fellow bloggers such as Rick Beckman and remove the dates from your URLs.

How to remove the “year/month/date” portion of dated permalinks

Although there are free WordPress plugins available for changing your permalinks, we prefer to handle URL redirection with Apache/htaccess rather than PHP because it requires fewer system resources and is executed with greater speed. One final note before we begin: the purpose of this tutorial involves removing date information from all future permalinks and redirecting all preexisting permalinks to their restructured counterparts. Thus, if you are setting up permalinks for a new blog (or one with only a few posts), the second part of this tutorial may not be required — a simple change of permalink structure via the WP Admin (as explained below) may be all that is needed. That said, let’s begin..

Part 1: Update your WordPress Options

The first step in creating “post-name-only” permalinks is to update your WordPress permalink structure in the Permalinks Options page of the WordPress Admin. Using the Custom structure option, customize your permalink structure as follows:

/%postname%/

After entering the post-name-only permalink structure, save the changes and test your pages. Remember to check different types of views — home, single, archive, page, search, etc. — to ensure that your new permalinks are working as expected. Once this is done, all future posts will feature the dateless permalink structure. In the second part of our tutorial, we will redirect all requests for old versions of your URLs to their newly configured counterparts.

Part 2: Update your htaccess file

The second step in creating “post-name-only” permalinks involves modifying your root or subdirectory htaccess file to ensure that old permalinks are redirected to, and served as, your new permalinks. Examine each of the scenarios described below, determine which method applies to your specific setup, and implement the required steps.

Option 1: Remove “year/month/day” from permalinks with WordPress installed in the ROOT directory

This method removes the “year/month/day” portion of permalinks for blogs located within the domain’s root directory. So if your old permalinks looked like this:

http://domain.tld/2008/08/08/post-title/

..then the htaccess code provided in this section will transform them into this:

http://domain.tld/post-title/

Locate your blog’s permalink htaccess rules. Then, place the following code directly after the line containing the RewriteBase directive:

# remove all permalink date info for blog in root directory
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?$ http://domain.tld/$4/ [R=301,L]

Remember to edit the “domain.tld” to match that of your own. No other changes are necessary. Test like crazy. After verifying that everything works as intended, sit back and enjoy your new optimized permalinks!

Option 2: Remove “year/month/day” from permalinks with WordPress installed in SUBDIRECTORY

This method removes the “year/month/day” portion of permalinks for blogs located within a subdirectory. So if your old permalinks looked like this:

http://domain.tld/subdirectory/2008/08/08/post-title/

..then the htaccess code provided in this section will transform them into this:

http://domain.tld/subdirectory/post-title/

Locate your blog’s permalink htaccess rules. Then, place the following code directly after the line containing the RewriteBase directive:

# remove all permalink date info for blog in subdirectory
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?$ http://domain.tld/subdirectory/$4/ [R=301,L]

Remember to edit the “domain.tld/subdirectory” to match that of your own. No other changes are necessary. Test like crazy. After verifying that everything works as intended, sit back and enjoy your new optimized permalinks!

Option 3: Remove “year/month” from permalinks with WordPress installed in ROOT directory

This method removes the “year/month” portion of permalinks for blogs located within the domain’s root directory. So if your old permalinks looked like this:

http://domain.tld/2008/08/post-title/

..then the htaccess code provided in this section will transform them into this:

http://domain.tld/post-title/

Locate your blog’s permalink htaccess rules. Then, place the following code directly after the line containing the RewriteBase directive:

# remove year and month info from permalinks for blog in root directory
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)/?$ http://domain.tld/$3/ [R=301,L]

Remember to edit the “domain.tld” to match that of your own. No other changes are necessary. Test like crazy. After verifying that everything works as intended, sit back and enjoy your new optimized permalinks!

Option 4: Remove “year/month” from permalinks with WordPress installed in SUBDIRECTORY

This method removes the “year/month/day” portion of permalinks for blogs located within a subdirectory. So if your old permalinks looked like this:

http://domain.tld/subdirectory/2008/08/post-title/

..then the htaccess code provided in this section will transform them into this:

http://domain.tld/subdirectory/post-title/

Locate your blog’s permalink htaccess rules. Then, place the following code directly after the line containing the RewriteBase directive:

# remove year and month info from permalinks for blog in subdirectory
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)/?$ http://domain.tld/subdirectory/$3/ [R=301,L]

Remember to edit the “domain.tld/subdirectory” to match that of your own. No other changes are necessary. Test like crazy. After verifying that everything works as intended, sit back and enjoy your new optimized permalinks!

Option 5: Remove the “year” from permalinks with WordPress installed in ROOT directory

This method removes the “year” portion of permalinks for blogs located within the domain’s root directory. So if your old permalinks looked like this:

http://domain.tld/2008/post-title/

..then the htaccess code provided in this section will transform them into this:

http://domain.tld/post-title/

Locate your blog’s permalink htaccess rules. Then, place the following code directly after the line containing the RewriteBase directive:

# remove year info from permalinks for blog in root directory
RewriteRule ^([0-9]{4})/([^/]+)/?$ http://domain.tld/$2/ [R=301,L]

Remember to edit the “domain.tld” to match that of your own. No other changes are necessary. Test like crazy. After verifying that everything works as intended, sit back and enjoy your new optimized permalinks!

Option 6: Remove “year” from permalinks with WordPress installed in SUBDIRECTORY

This method removes the “year” portion of permalinks for blogs located within a subdirectory. So if your old permalinks looked like this:

http://domain.tld/subdirectory/2008/post-title/

..then the htaccess code provided in this section will transform them into this:

http://domain.tld/subdirectory/post-title/

Locate your blog’s permalink htaccess rules. Then, place the following code directly after the line containing the RewriteBase directive:

# remove year info from permalinks for blog in subdirectory
RewriteRule ^([0-9]{4})/([^/]+)/?$ http://domain.tld/subdirectory/$2/ [R=301,L]

Remember to edit the “domain.tld/subdirectory” to match that of your own. No other changes are necessary. Test like crazy. After verifying that everything works as intended, sit back and enjoy your new optimized permalinks!

Wrap it up..

Using your choice of the methods described above, it is possible to optimize and maximize your WordPress permalinks for greater usability, better performance, and enhanced SEO value. Many thanks to Rick Beckman for his idea, insight, and inspiration regarding the process of removing dates from permalinks. And, as always, please share any questions, comments, or criticisms in the comments area below.

God Bless!

Footnotes

  • 1 This post was written shortly after Rick Beckman inquired about removing the post-date information from his permalink URLs. After discovering a solution, I wrote this article to explain the method, and intended to post it upon returning to the office. After finishing the article, I was surprised to learn that Rick had already discovered a similar solution, implemented it at his site, and published an excellent article explaining his process. Having said that, I tip my hat to Rick for beating me to the punch, and have decided hesitantly to share my write-up on the technique. In addition to the information provided in Rick’s article, this post expands context, explores consequences, and presents an alternate technique including multiple configurations for custom permalinks.

About the Author
Jeff Starr = Designer. Developer. Producer. Writer. Editor. Etc.
Blackhole Pro: Trap bad bots in a virtual black hole.

58 responses to “Permalink Evolution: Customize and Optimize Your Dated WordPress Permalinks”

  1. Jon Peltier 2009/02/06 7:20 pm

    I made the change to my .htaccess file a couple weeks ago, and it handled the redirect to my new permalink structure perfectly. Thanks!

    But…. The .htaccess file seems to have reverted back to its prior configuration in the past day or two. I’ve fixed it, but why would this have changed? Does WordPress or one of its more common plugins make these changes for me without my approval? I’d really like not to have to test this every few days.

  2. Jon Peltier 2009/02/06 7:31 pm

    Ha, it was the Robots Meta plug-in. I’ve updated the .htaccess information in its settings, and I should be good to go.

  3. Jeff Ivany 2009/02/07 4:34 am

    @Jon Peltier: I noticed this same problem a while back. Your post made me check my own .htaccess file just now and I finally clued in to what might be the problem. It seems that every time you update (or add?) a plugin in WordPress it causes the WordPress block within the .htaccess file to be regenerated.

    I wonder if WordPress considers this a feature or a bug?

    Jeff

  4. Jon Peltier 2009/02/07 6:26 am

    This would be a feature, right? When a program does something for your own good, even without asking you first?

    Fortunately WordPress has few of these “features”.

  5. @Jon Peltier: I have seen this happen while working on other servers for clients, et al. Media Temple’s servers are notorious for rewriting WordPress permalink rules every time a page is requested. Other servers rewrite/re-include the default permalink rules as well, and there seems to be no way of controlling the “feature” without hacking the core. In this case, you lucked out, in that it was only a plugin that was responsible. Glad to hear you got it working!

  6. Web-Betty 2009/02/13 1:01 pm

    Thank you for such a great article. I was really worried about changing my permalink structure, until I came across it.

    I have to say, I was totally prepared to have to make all these edits to my htaccess code, but I didn’t have to do anything at all. My default permalink was just to the post id. I changed it to the post ID/post title, and when checking the OLD permalinks, they worked just fine. I didn’t have to do anything else at all.

    I wonder if this is because I chose to use the post ID, and include it first? It’s a mystery to me, but I’m thrilled none-the-less.

    Thank you!

    Melissa

  7. Jeff Starr 2009/02/15 9:26 am

    @Web-Betty: Thanks for the feedback. I think newer versions of WordPress feature an automatic redirect to old URLs if you change your permalink structure. I may be wrong about this, but I thought I had read about that somewhere and thinking, “so much for the accuracy of that post!” Ah well, great to hear things went well for you! ;)

  8. Web-Betty 2009/02/17 6:55 pm

    Your article was instrumental in helping me “pull the trigger” on the post URL change, so thank you again.

    I have subscribed to your blog, I really enjoy it. :)

  9. Jeff Starr 2009/02/17 9:38 pm

    Thank you, Web-Betty! I am honored to appear in your feed reader! :)

  10. Ahmed Suhail 2009/07/15 2:25 am

    Hey Jeff,
    I’m trying to access the permalinks options page in the admin cp, but a white page appears with “done, but with errors on page” on the status bar
    I tried all .htaccess changes, but it still shows 500 internal server error
    thanks in advance

  11. Jeff Starr 2009/07/15 9:07 am

    Not sure what the issue might be, Ahmed. You may want to try upgrading or re-installing WordPress. Good luck.

  12. Hi. Very good article, but I need a help.

    I use wordpress on a linux server.

    I set permalinks but I have some problems with a couple of things.

    How to rewrite & permalink like “domain.com/fr/aticle-title” this 2 address

    domain.com/?p=228&lang=fr
    domain.com/index.php?p=228&lang=fr

    The second problem is this:

    domain.com/article-title/?lang=fr" must be "domain.com/fr/article-title/

    The third is to know how to modify variable sequency in permalink

    domain.com/index.php?p=228&lang=fr&tag=ferry" must be "domain.com/fr/ferry/article-title/

    I need to know how to modify htaccess file or if there is a wordpress plugin and how to set it.

    tks for the help and sorry for the bad english!!!

    Marco

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
USP Pro: Unlimited front-end forms for user-submitted posts and more.
Thoughts
I live right next door to the absolute loudest car in town. And the owner loves to drive it.
8G Firewall now out of beta testing, ready for use on production sites.
It's all about that ad revenue baby.
Note to self: encrypting 500 GB of data on my iMac takes around 8 hours.
Getting back into things after a bit of a break. Currently 7° F outside. Chillz.
2024 is going to make 2020 look like a vacation. Prepare accordingly.
First snow of the year :)
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.