If you’re hosting your WordPress blog on a
mod_rewrite-enabled Apache web server, you can use this feature to make your post URLs prettier.
By default, WordPress uses an ugly format like
http://yoursite/?p=795 (this URL is for post #795, just in case you’re wondering). If your server has
mod_rewrite enabled, you can also use more descriptive URLs as suggested by WordPress:
As you can see, I’m using a custom permalink structure defined as
/%post_id%/%postname%/; therefore the URL for this post is:
%post_id% represents the unique ID number for the post and
%postname% represents the sanitized version of the post title.
Those percentage sign sandwiched words you see above are what WordPress calls Structure Tags. From that linked page, you can find more structure tags that you can use to form nicer post URLs.
Here are some sample custom post URL structures you can use (along with the sample resulting URLs):
As you can see, you are not limited to using slashes to separate the structure tags. You can also append extensions such as
.php in your post URL structure. I prefer to have the post ID appear in the URL so I can immediately use SQL queries to modify the post data if the need arises.
So if you’re starting a new blog (or helping someone setup theirs), try to make use of the custom post URL structure function. It’s quite boring to see a lot of blogs still using either the ugly URL structure or the very common date based URLs. Use this guide and your creativity to make your own unique post URLs!