This is probably another one of those situations that applies only to me, but just in case someone else out there happens to have this same broken permalink issue, I’ll describe what happened to my site, and how I fixed it.
The specifics of my setup were: WordPress 3.4.1, WordPress SEO 1.2.5, and the custom permalink structure
/%category%/%postname%/. The problem that someone thankfully alerted me to (gotta get back in the habit of checking Google WMT regularly) was that my permalinks were broken. Specifically, sub-category or paginated permalinks such as
/articles/page/2/ either redirected to entirely the wrong page, or returned a 404. Post and page and WooCommerce URLs on the other hand worked just fine. Likewise, top-level category urls like
/articles/ or /news/ were also unaffected.
When I first set up this site I decided to structure my post permalinks so they would consist of any categories followed by the post title. Take for instance this very URL
/articles/wordpress/wordpress-pretty-category-permalinks-broken-and-fixed/, it’s pretty clear that this is a WordPress article about fixing broken category permalinks. I feel like this structure results in a very intuitive and easy to navigate site, both for search engines as well as for users. To achieve this result I configured WordPress Settings > Permalinks: Custom Structure as
Setting the Custom Structure gets you most of the way there, but despite leaving the category base blank, WordPress defaults it to ‘category’, meaning that rather than a nice permalink like say
/articles/magento/how-to-upgrade-magento I get
/category/articles/magento/how-to-upgrade-magento. Even worse than just having the extra directory level cluttering up my nice clean URL is the fact that the ‘category’ page doesn’t even exist: visiting
/category/ returns a 404.
The solution is to use a plugin a remove that category base, there are a number of options available for this, I happened to use the one provided by WordPress SEO as I was using that plugin anyways. This can be enabled by going to SEO > Permalinks and checking the box next to “Strip the category base (usually /category/) from the category URL.” and gave me exactly the URL structure I was trying to achieve.
And so the permalinks worked perfectly fine until recently, I suppose after updating WordPress SEO. After playing around with a backup of this site on my development machine for a few hours, I finally realized that all permalinks worked properly if I just included that default base category ‘category’. That is to say,
It didn’t take me much longer to remember and find that little WordPress SEO category base setting from oh so long ago. Knowing that sometimes permalink issues can be fixed by simply saving the WordPress permalink settings page, I went back to the SEO > Permalink page and saved the settings. That must have refreshed or regenerated the permalinks and fixed the problem.
- broken “pretty” category permalinks
- WordPress 3.4.1
- Permalink Custom Structure:
- WordPress SEO 1.2.5 to Strip the category base
- Go to Settings > Permalinks and click “Save Settings”
- Go to SEO > Permalinks and click “Save Settings”