So, there could be many reasons as to why your “Post name” permalinks are not working in WordPress, but this post deals with one of most common which apparently doesn’t have to do with the WordPress setup or configuration but with the server settings.

The issue in particular is when your posts URL, like the one below, works:
http://www.thedevlogs.com/?p=123

But the named URL for the post like the one below, doesn’t:
http://www.thedevlogs.com/why-post-name-permalinks-not-working-wordpress

The first approach should be to put the default .htaccess for WordPress in the root directory of your setup and see if that works. You may get the default .htaccess code from the official WordPress codex page itself:

https://codex.wordpress.org/htaccess

If adding/replacing the .htaccess doesn’t work then you may continue reading below and try the solution mentioned.

This issue is most commonly faced when you have migrated to a new server, or you are launching your WordPress site on a VPS or on a Virtual Machine on AWS, Azure, Digitalocean droplet etc, and the configuration is not correct.

What happens is that the setting to allow WordPress to override the “routes” is not set in the apache2 conf file. Taking an example of an Ubuntu Server, your default apache2.conf will look like this:

Path: /etc/apache2/apache2.conf (here we have an example of /var/www):

***** snippet *****

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

And to allow WordPress to be able to change the URLs as desired by the admin in the permalinks settings, you have to change the option “AllowOverride” to “All”. So, the final snippet will look like this:

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

After making this change, you’d also have to restart apache. You may use the following command for the same:

sudo service apache2 restart

In case the issue is still not resolved then you may have to enable “module rewrite” on the server as well. You may do so by running the following command:

sudo a2enmod rewrite

and then again:

 sudo service apache2 restart 

This, in theory, should solve the issue in most of the cases. If not, then further investigation is required.

Again, there are countless other ways this setting could be configure, for example, some system admins don’t wish to change the default config file for apache and prefer to set this setting in the “sites-available” config file, and there’s always a chance that other settings on the server are causing the issue as well. So in case any of you guys reading this has anything useful to contribute or point out, please share in the comments section below.

Thanks again and Happy Coding 🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.