Fall Sale! Code FALL2024 takes 25% OFF our Pro Plugins & Books »
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 = Web Developer. Book Author. Secretly Important.
Banhammer: Protect your WordPress site against threats.

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

  1. Ibnu Asad 2008/02/06 5:02 pm

    @Perishable: Everything is working well and since I didn’t really know any fancy .htaccess tricks, I manually added a 301 redirect for about 26+ posts.

    When I changed the permalink structure and added the redirect, Google’s index of my site were really screwed up for about 1 week. After that Google finally updated the index with the new permalink structure :)

  2. Ibnu Asad 2008/02/06 4:11 pm

    Yet Another Amazing Informational Post :) My blog was previously using the following permalink structure:

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

    After a few months using the permalink structure, I realized that the permalink was just too long and there’s really not much point including the date info on the permalink as the date info are already displayed on the post itself.

    Too keep things simple, I now use the following permalink structure:

    /%post_id%/%postname%/

  3. Rick Beckman 2008/02/06 4:12 pm

    Thanks for the multiple nods! I’m glad to see that you went ahead and posted this; it’s great information, definitely going a step further than I did.

    Also, if anyone is interested, I’ve been using my shortened permalinks for several weeks now, and thus far, I have had no problems as a result of the switch over.

    I have noticed that Google sometimes displays an article twice — at both URIs (old and new) — but as Google updates, the old will fade out and the new (which shows up exclusively in my sitemap now) will prevail, so to speak.

  4. Perishable 2008/02/06 4:40 pm

    I am happy to see some comments getting through despite the severe server outages I have been experiencing. My apologies for any issues accessing the site. That said..

    @Ibnu: Thanks for the compliment — you are too kind! I like the permalink structure you have chosen. I have not seen many blogs using that format. Has everything been working well since the change? Also, I am curious as to which (if any) permalink redirection method you are using for your old posts.

    @Rick: Of course, dude! I had to give you mad shouts for throwing down in such devastatingly tuff fashion. Your article blew me away to the point that I was almost too scared to even think of posting my version ;)

    Also, it is excellent to hear that you have not been experiencing any problems with your new permalink structure. As for duplicate indexing, I am confident that the “Big G” will eventually work everything out! :)

  5. I’m just trying dateless permalinks on a new site (not yet live), and I’ve found one problem. If I change permalinks so that this URL for a single post:

    http://domain.com/2008/02/post-name/

    Becomes:

    http://domain.com/post-name/

    Then the monthly archive URL:

    http://domain.com/2008/02/

    Returns a 404. My htaccess uses the usual generic rewrite block:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    Would I need to add custom rewrite rules for the date archives?

  6. Perishable 2008/02/10 4:35 pm

    Steve, the problem may be the trailing slash in the rewrite rules. Try removing the trailing slash from the rewrite target as follows:

    # 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]

  7. Perishable 2008/03/02 2:24 pm

    Update: Here are a few alternate techniques that seemed too redundant for the article, but just might prove useful nonetheless:

    # update permalinks by removing post month and day
    RewriteEngine On
    RewriteBase /
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?$ http://domain.tld/$1/$4/ [R=301,L]

    # update permalinks by removing post month and day (alternate method)
    RedirectMatch permanent ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/([a-z0-9\-/]+) http://domain.tld/$1

    # update permalinks by removing post day only
    RewriteEngine On
    RewriteBase /
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?$ http://domain.tld/$1/$2/$4/ [R=301,L]

    # update permalinks by removing post day only (alternate method)
    RedirectMatch permanent ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/([a-z0-9\-/]+) http://domain.tld/$1

    Hopefully something there will help somebody trying to modify month/day and/or day-only permalinks. I just hate to delete potentially useful code! ;)

  8. This was useful for me – I appreciate the htaccess advice especially, as I am transitioning to a new permalink structure.

  9. Perishable 2008/04/08 7:34 am

    That’s great, MPB — good luck with the transition! :)

  10. Austin | OOHic.com 2008/05/14 4:09 am

    Thanks for sharing this wonderful information. I’ve already bookmarked your site :)

    I have a question:

    How about a case wherein the blog is installed in a sub-directory called “blog” and I want to use a permalink as http://domain.tld/blog/category-name/post-title

    Can you please help?

    Thanks!

  11. Perishable 2008/05/14 8:25 am

    Hi Austin, thanks for the kind words; I am glad that you find the site useful :) As for your permalink question, it should be fairly straightforward, depending on your level of familiarity with WordPress. The first thing you need to do is backup both your files and your database. Then, go to the Permalink Options screen in your WordPress admin and select the “Custom” permalink option. Then, right below that, enter the following permalink format:

    /%category%/%postname%/

    ..and click “Update Permalink Structure” to save the changes. After doing so, WordPress should have generated a set of htaccess rules at the bottom of that same admin page. Copy and paste that code into your blog’s root htaccess file and upload to your server. And that should be all there is to it. Good luck!

  12. TheMystical 2008/05/19 5:37 pm

    Awesome, I didn’t plan ahead while working on my site and used the data permalink structure, it looked awful but thank to your tips now it’s much better.

    Just one word of “caution”, if you have your stories/articles dugg and have the digg badge in your post, they’ll all reset to none. That actually make sense, technically the links were changed and digg.com keep looking for the ones that were originally submitted. Would be nice to be able to fix that somehow :-)

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 »
GA Pro: Add Google Analytics to WordPress like a pro.
Thoughts
Went out walking today and soaked up some sunshine. It felt good.
I have an original box/packaging for 2010 iMac if anyone wants it free let me know.
Always ask AI to cite its sources.
All free plugins updated and ready for WP 6.6 dropping next week. Pro plugin updates in the works also complete :)
99% of video thumbnail/previews are pure cringe. Goofy faces = Clickbait.
RIP ICQ
Crazy that we’re almost halfway thru 2024.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.