Enabling Pretty Permalinks

I just struggled to enable pretty permalinks in WordPress 4.5.3 on Ubuntu 14.04 running Apache 2.4.7.  After enabling the permalink I wanted, all pages gave 404 errors.

requested URL ### was not found on this Server.

After troubleshooting permissions on the .htaccess file, I stumbled across the comment on serverfault mentioning that you need to set ‘AllowOverride’ to ‘All’ in

/etc/apache2/apache2.conf

for the Directory /var/www/ like such:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

But wait, there’s more!  I have a multi-tenant setup, so I also had to go into

/etc/apache2/sites-available/dansagner.conf

And make the same ‘AllowOverride All’ change in that configuration file.

All told, we needed to:

  • Give WP access to .htaccess
  • Ensure the correct code was being written to .htaccess
  • Enable mod_rewrite with
    sudo a2enmod rewrite
  • Set ‘AllowOverride All’ in
    /etc/apache2/apache2.conf
    and in
    /etc/apache2/sites-available/dansagner.conf
  • Restart apache with
    sudo service apache2 restart

And celebrate!

Leave a Reply

Your email address will not be published. Required fields are marked *