How to Fix Permalink Issues on WordPress

Are you having issues with your WordPress website’s Permalinks? Learn how to troubleshoot and fix Permalink issues to improve your website’s URL structure and functionality.

These methods worked for me.

Reza Rafati

Errors which might be fixed with this guide

The requested URL was not found on this server.
Wordpress REST API (wp-api) 404 Error: Cannot access the WordPress REST API
WordPress Page or Post does not Update / Save

Permalinks check your WP-JSON page

The WordPress REST API (wp-api) is a powerful tool that allows developers to interact with WordPress sites using HTTP requests.

Essentially, it enables them to retrieve, update, and delete data from WordPress sites programmatically, without needing to log in to the site’s admin panel.

Not Found
The requested URL was not found on this server.

It’s worth noting that the WordPress REST API (wp-api) is often enabled by default in WordPress, which means that many themes and plugins use it to interact with your website’s data.

This can include things like displaying content on other platforms or integrating your website with third-party applications.

Issues with saving WordPress Posts and Pages

If you’re encountering issues with the wp-api, the first page you’ll want to check is the wp-json page.

WP-JSON Permalink issue
WP-JSON Permalink issue

This page serves as the main entry point for the wp-api, and it should be accessible at a URL like “yoursite.com/wp-json/”.

If you’re able to access the wp-json page without any issues, it’s a good sign that the wp-api is functioning correctly.

yoursite.com/wp-json/

However, if you’re encountering a 404 error when trying to access the wp-json page, it could be an indication that there are issues with your website’s Permalinks.

How To Fix The Permalinks Issue

Apache2 a2enmod module should be enabled

Make sure the a2enmod module is enabled and used in the Apache2. You can do this by using the following command:

sudo a2enmod rewrite

This Enables Permalink structure rewrites by WordPress

https://example.com/2023/post-name/
https://example.com/2023/04/18/post-name

Check Your .HTACCESS file

Your .htaccess file might be broken. The webserver might not be able to read it, or WordPress might not be able to change it. In order to fix this, we need to follow the following steps:

  1. Fully delete .htaccess from your /var/www/ folder (or the location where you have placed your WordPress website).
  2. Navigate to your WordPress website and find the Permalinks settings page
  3. Change and save the Permalinks settings to a different permalinks structure
  4. Check if a new .htaccess file has been created.
    • If yes, well done, Permalinks and WP-JSON should work now.
    • If no, we need to continue
  5. If it didn’t work, we need to be sure that Apache has ownership of the folders and files.
    • sudo chown -R www-data:www-data /var/www/wordpress
    • sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
    • sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;
  6. Try to create the .htaccess again via the WordPress Permalinks settings page
  7. If it stil doesn’t work, continue to the Check Your Apache and Virtual Configuration File steps.

Check Your Configuration Files

Apache

Open this configuration file

/etc/apache2/apache2.conf

Search for <Directory /var/www/>

<Directory /var/www/>

And change this value

AllowOverride None

To this value

AllowOverride All

So it looks like this:

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

Save it and restart apache

sudo systemctl apache2 restart

Retry your permalinks settings

Virtual Configuration file

Open your default configuration

nano sites-enabled/000-default.conf

And make sure the following is in the Virtual configuration file

    DocumentRoot /var/www/html
    <Directory /var/www/html>
        AllowOverride All
    </Directory>

Save it and restart apache

sudo systemctl apache2 restart

Retry your permalinks settings

Share This Message