Fix WordPress 404 Errors: Rewrite Slug and URL Conflicts

If some of your WordPress URLs return a 404 error while the rest load normally, this is typically caused by stale rewrite rules or a conflict between content types sharing the same URL format.

Each custom post type has a permalink structure, and part of that structure is the rewrite slug. WordPress reads this slug to decide which content to load from the database for a given URL.

You can override it when registering the post type, but using the same slug for multiple content types often leads to 404 errors or redirect loops.

This guide covers how to identify these conflicts, resolve them, and keep your custom post types loading correctly.

Key Takeaways

  1. Partial 404s (some URLs work, some do not) usually point to conflicting or stale rewrite rules.
  2. When two content types share the same permalink structure (use the same rewrite slug), one type's URLs load correctly while the other's return a 404 error.
  3. If a page and a custom post type share the same slug, keep the slugs distinct or use a custom permalink plugin to resolve the conflict.

Why Only Some of Your URLs Return Error 404

When troubleshooting a 404 error, first check whether every URL on your site is affected or only specific ones. This simple check often points directly to the underlying cause.

  • If every URL, including the homepage, returns an error 404, the problem is usually related to the server configuration or rewrite rules that have not been flushed.
  • If the homepage, regular posts and pages work correctly but only a particular custom post type's URLs return a 404 error, the problem usually comes from a rewrite rule conflict.

To understand why this happens, it helps to know how WordPress matches a URL to the content it should display.

What is a Rewrite Slug and How to Change It

When you register a custom post type or taxonomy, the rewrite slug is the segment of the URL that appears before the individual post or term name. WordPress uses it to build the rewrite rule (see next section) and to tell one content type apart from another within a URL.

You define it via the rewrite argument when registering the content type.

function custom_post_type_registration() {
	 $args = array(
		'public' => true,
		'label' => 'Book',
		'supports' => array( 'title', 'editor', 'thumbnail' ),
		'rewrite' => array( 'slug' => 'publication' ),
	 );
	 register_post_type( 'book', $args );
}
add_action( 'init', 'custom_post_type_registration' );

For example, suppose your custom post type is named "Book" and you set its rewrite slug to publication . The sample permalink then looks like this:

https://example.com/publication/a-sample-cpt-permalink

If you omit the rewrite argument, WordPress uses the post type name instead, so the base becomes book :

https://example.com/book/a-sample-cpt-permalink

How WordPress Decides Which Content a URL Points To

WordPress stores its rewrite rules in a list known as the rewrite rules array. Each rule is a regular expression that is checked against a requested URL to determine which content should be retrieved from the database.

A standard rule for posts and pages is:

^/([^/]+)/?$

This pattern matches a simple URL such as https://example.com/about/hello-world/ and tells WordPress to load the page with the slug hello-world (the child page of the parent page about ).

A sample rewrite rule in action

This first-match rule functions correctly when each content type has its own distinct permalink format. Problems begin when different rules match the same URL, which is where most conflicts typically occur.

Where These URL Conflicts Actually Come From

The rewrite system is simple and efficient, but that simplicity is also the source of most URL conflicts. WordPress checks the rules one by one and stops at the first match. If two content types use the same permalink structure, both rules match the same URL.

The first matching rule always takes precedence. If that rule belongs to a different content type than the requested URL, WordPress returns a 404 response. This happens silently, without any admin notice or warning. Below are the most common setups where this happens.

A Page and a Custom Post Type With the Same Slug

Many of the people who ask whether Permalink Manager can fix their URL conflict turn out to have the same kind of setup. This happens when a page, for example "Cars" using the slug cars , shares its permalink structure with a custom post type that uses the same slug.

The page and custom post type match the same permalink format (rewrite rule).

In this situation, accessing the page URL may return a 404 error even if the page is published. This happens when the page slug matches a rewrite rule used by a custom post type, so WordPress tries to load the custom post type archive instead of the standard page.

For this reason, many themes and plugins use unusual-looking slugs such as portfolio-item for their custom post types.

If you do not need both to use the same slug, there is no need for a custom permalink plugin or a code snippet. The usual fix is simply to keep the two slugs distinct. You can change the page slug, or adjust the rewrite slug of the affected custom post type.

Setting the Rewrite Slug to a Single Slash

This case is a variation of the issue described above. The difference is that it affects more than one page. It happens when the rewrite rules for standard pages overlap with the malformed permalink rules for custom post type items.

This overlap occurs when a custom post type's rewrite slug is set to / , which removes its base.

...
'rewrite' => array( 'slug' => '/' ),
...

At first glance this looks correct, but it will not behave the way you expect. Setting the slug this way overwrites the rewrite rules for built-in posts and pages, which leads to broken links, 404 errors, and content that can no longer be reached.

The reason is how WordPress handles permalinks. By design, it does not allow the same permalink format to be shared across different content types.

Remove rewrite slug

When a custom post type has no distinct rewrite slug, WordPress may resolve URLs in one of two ways depending on rule priority. In both cases, part of the content may become unavailable:

  1. WordPress may treat your pages and posts as custom post type items, so those pages and posts return 404 errors.
  2. Or WordPress may ignore the custom post type's rewrite rules, so the custom post type items return 404 errors instead.

WooCommerce and the Shop or Product Base

This problem is frequently seen in WooCommerce-based stores and is not widely described in official documentation. It often appears in support requests on WordPress.org where users encounter unexpected 404 errors without understanding the cause.

The issue usually starts after removing the /product/ or /product-category/ base in "Settings -> Permalinks" to achieve shorter product URLs. This can lead to 404 errors across the entire website.

Unfortunately, WordPress does not alert users that changing or removing rewrite bases in this way can break existing links.

WooCommerce default settings

Cache, Stale Rewrite Rules or Server Misconfiguration

Most 404 errors are caused by conflicts in rewrite rules or an outdated rewrite rules array, but this is not the only possible cause.

The problem can also be caused by cached content, either at the server level or in the browser. In such cases, testing the page in an incognito or private browsing window helps rule out browser cache interference.

If the error page appears as plain text with no styling, like in the examples below, this usually points to a missing or corrupt .htaccess file, or an NGINX configuration issue.

Apache WordPress 404 error
If your server is running Apache, you will see this page as the default error page.
404 page on NGINX servers
This is the default error page for NGINX servers.

How to Fix It

Flush the Rewrite Rules

Stale rewrite rules are one of the most common causes of 404 errors that appear after updating a plugin or theme, or server migrations. WordPress keeps rewrite rules cached in the database, and they are not always regenerated automatically.

Keep Rewrite Slugs Unique

If flushing the rewrite rules did not fix the problem, the cause is most likely two content types sharing the same base. Review your custom post types and taxonomies, and confirm that each one uses a unique rewrite slug. To prevent URL conflict, avoid overriding the rewrite slug unless necessary.

WordPress sets it to the post type name by default, and that name is already unique. Change it only when you need a custom structure, and when you do, make sure the new value is not already used by a page, another post type, or a taxonomy.

Flushing the rewrite rules often fixes the problem without additional troubleshooting. Follow the steps below to proceed:

  1. Go to the admin page "Settings -> Permalinks".
  2. Flush the rewrite rules and clear their cache by clicking "Save changes" even if no change has been made.

Save changes to flush rewrite rules

If the 404 errors no longer appear after this step, you are all set and no further action is needed. If they persist, please continue with the troubleshooting steps below.

If you need the same permalink format across several custom post types and/or taxonomies, for example to mimic hierarchical content structure, you can use a tailored code snippet that overwrites the 'query' object before WordPress builds the database query.

If you would rather avoid code, or the snippet does not work as expected, a dedicated custom permalink plugin is usually the better choice.

Permalink Manager
Permalink Manager is often used to resolve URL conflicts, especially when different post types or taxonomies must share the same permalink base.

You can use it to remove the permalink base from custom post types and taxonomies or duplicate rewrite slugs.

Fix Server-Level 404 Errors

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 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.

If the .htaccess file is missing or corrupted, WordPress cannot properly update the settings, which could cause server-level "404" errors with URLs.

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.

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.

 

.htaccesss file location
Both the wp-config.php and .htaccess files should be located in the same directory.

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
The code snippet above is only suitable for a standard single-domain installation. This code is different if you are running a multisite/network website. Official documentation has further information about the default .htaccess file.

FAQ & Troubleshooting

Seeing a "Page Not Found" error after updating URLs is a common issue. This usually happens for a few common reasons.

  1. Server permissions:
    The .htaccess file (Apache) needs to be updated when you change the permalink settings and flush rewrite rules. If WordPress does not have the right permissions to write new rules to those config files, the new settings will not take effect.
  2. Missing redirects:
    WordPress does not automatically create redirects when permalinks are changed, so when a visitor clicks an old link, the server looks for a page that is no longer there.
  3. Outdated cache:
    Your site might be serving stale URLs from page cache, object cache, CDN, or browser cache. Clearing all active caches is usually a good first troubleshooting step.
  4. Rewrite rule conflicts:
    Using the same permalink structure for custom post types and taxonomies can lead to URL conflicts. When two rules match the same URL structure, WordPress cannot determine which content item to display.

Why Do Bricks and Elementor Break From URL Conflicts?

Rewrite rule conflicts can also be caused by third-party plugins. These conflicts can affect both WordPress itself and other plugins.

For example, using the same permalink structure for multiple content types, or removing the rewrite slug from a custom post type, can stop editors like Bricks or Elementor from working correctly.

When this happens, editors like Bricks and Elementor can get stuck during loading, showing messages like "Invalid post type" or "The preview could not be loaded".

Last updated by Maciej Bis on: June 1, 2026.


Maciej BisFounder of Permalink Manager & WordPress Developer

The developer behind Permalink Manager, a plugin for managing permalinks, has been working with WordPress, creating custom plugins and themes, for more than a decade.

Leave a Reply

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