A "404 error" is a common issue with permalinks, often caused by incorrect rewrite rule settings. Before checking more complex solutions, try resetting the rewrite rules. It is a quick fix that often does the trick.
This issue often appears after installing a new plugin or declaring custom post types and taxonomies. Usually, you can fix it easily from the WordPress dashboard if you have admin access.
A good first step is flushing the rewrite rules. This makes WordPress refresh its settings and update the server configuration behind the scenes. Since it only takes a few clicks, it is worth trying before exploring more complex solutions.
That said, it is not always that straightforward. If the problem comes from a server misconfiguration or a faulty .htaccess file, you may need to look beyond WordPress settings and do some troubleshooting.
How to Flush Rewrite Rules?
Flushing the rewrite rules cache may resolve 404 errors caused by plugins or themes updates. It is possible that the issue originated from WordPress utilizing an outdated, cached version of rewrite rules.
To flush the rewrite rules cache, please follow these steps:
- Go to the admin page "Settings -> Permalinks".
- Flush the rewrite rules and clear their cache by clicking "Save changes" even if no change has been made.
By now, the .htaccess file should have been created and the rewrite rules applied. But if you're still seeing the 404 error, you might want to try doing the process again manually using FTP.
Why You Might Need to Flush Rewrite Rules in WordPress?
There are a few common situations where you may need to flush your rewrite rules.
- Changing permalink structure via built-in settings
- Adding custom post types and/or taxonomies
- Plugin or theme conflicts
- Server migration
- Redirect problems
How Are Rewrite Rules Working?
Rewrite rules are an important part of WordPress since they parse URLs to determine if they match any of the URL formats assigned to content types. These rules are a key part of the URL system, transforming pretty permalinks into database queries that allow WordPress to display the correct content.
You might not even know they exist because they are generated automatically whenever you declare new custom post types or taxonomies. Each content type has its own distinct URL format. This lowers the amount of database requests and helps WordPress to limit the query to items belonging to a single post type or taxonomy.
For example, when a visitor opens the URL shown below, WordPress recognizes it as a page because the URL follows the format typically used by pages.
https://example.com/sample/page

It then looks for a page in the database that matches the extracted "page" slug. If a match is found, WordPress will display the page. If no match is found, a "404 error" will be shown instead.
Troubleshooting
How to Check if Your Permalinks Are Set Up Correctly?
To see if pretty permalinks are working, try opening a subpage. If you get an error, the way it appears can help you identify the issue.
- If the error page matches the standard layout of your website, including the logo and footer, it could indicate a rewrite rules conflict.
- When an error appears with only basic text and no styling, the incorrect server configuration is likely the cause.
This article will focus on the second option. If you come across a server error, such as the ones listed below, the issue is probably due to a missing .htaccess file or an incorrect NGINX configuration.
The requested URL was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Server Configuration
To make the pretty permalink system work, WordPress needs either an .htaccess file (if you're using Apache) or an NGINX configuration file (for NGINX servers). These files help WordPress understand how to process and route clean URLs.
When you install WordPress, it automatically generates a .htaccess file. This file is used by Apache, or by NGINX servers if Apache is set up as the reverse proxy. This file includes important settings that determine how URLs are processed.
Whenever you change the built-in permalink settings or install certain plugins, WordPress updates these settings accordingly. If the .htaccess file is missing or corrupted, WordPress cannot properly update the settings, which could cause server-level "404" errors with URLs.
How to Restore the .htaccess File via FTP?
If your website still shows "404 errors" after flushing the rewrite rules in the admin panel, and you have FTP access, consider creating a .htaccess file in the root directory and inserting the default code.
Sometimes, the file exists but cannot be changed due to permission settings (CHMODs). Another possibility is that a faulty plugin may have deleted or modified it, overwriting any previous changes.

The default configuration file code is shown below. If the .htaccess file is not present, you will need to create it manually. Please copy, paste, and save the file with the default contents provided below.
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Leave a Reply