WordPress serves 404s after changing permalink structure

Problem
You decide to change your Permalink structure on WordPress. After you do, all your posts stop serving and return 404 errors, both at the new and old URLs. If you change your Permalink structure back to what it was before, your posts start serving again.

Solution
There are a couple things you should check:

1. Make sure your WordPress directory is writeable.
The directory were you installed WordPress should be writeable by WordPress. Typically, WordPress runs under the “www-data” user. You can “chown -R www-data $wp-home” to make “www-data” the owner of the directory. A possibly better solution is to make a new group, set the group owner of the directory to such group, and add www-data to the group. Whatever you do, make sure www-data (or whatever user WordPress runs as) has write access to the dir.

2. Make sure mod_rewrite is enabled on your Apache installation.
There’s a pretty good set of steps to follow to enable mod_rewrite here. In summary:

  • Check that you have mod_rewrite. There should be a rewrite.load file under $apache_home/mods-available. Apache is usually installed under /etc/apache2. If it’s not there, you might want to reinstall Apache httpd.
  • Enable mod_rewrite. “a2enmod rewrite” should do the trick (you may have to run it with sudo).
  • Allow overriding. Edit your default Apache config at /etc/apache2/sites-available/default. Find the text:
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    and change it to
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
  • Restart apache. You can do so with “sudo service apache2 restart”

After you’ve made sure of those two things, try setting your Permalink structure through WordPress again.

Hope that works! Let me know in the comments if it did or did not.