Fast random post in WordPress (with Apache’s help)

In this tutorial, I’m going to walk through how to use mod_rewrite‘s RewriteMap directive to redirect to a random WordPress post any time a visitor visits a specific URL, in this case /random. This technique is very fast, requires no PHP overhead beyond that which is normally needed to serve pages from WordPress, so it should be compatible with any caching methods being employed within WordPress. If you are using an upstream cache, like Varnish, you’ll need to exclude the URL you set up in the rewrite. Continue reading “Fast random post in WordPress (with Apache’s help)”