I have noticed I get an advantage using /%post_id%/%postname% since any mistake etc after sitename.com/123/wrong-words?some=params&etc=etc gets redirected to the correct post.

But for sitename.com/123/correct-full-postname/somemistakeword generates a 404.

Why is Wordpress not able to handle this /somemistakeword ? or why doesn't the redirection word when I add a / to the part of the postname url.

Is there anyway to fix this?

Edit: This seems to be default in all wordpress setups I tested.


Everything after the ? is considered part of the query string. Everything before the ? is part of the pretty permalinks, aka rewrite rules.

Rewrite rules are then processed to generate query variables. These are then plugged into a query ( which powers the main loop ), and a template is loaded based on this query.

The parameters that come after the ? in the URL can be used to add new query vars, or just plain GET variables.

So sitename.com/123/wrong-words?some=params&etc=etc is actually just sitename.com/123/wrong-words as far as the rewrite rule system is concerned. Rewrite rules are also powered by regular expressions, and the regular expression used to match a blog post, depends on how your pretty permalinks are configured.

Because of this, the same data is extracted from sitename.com/123/correct-full-postname and sitename.com/123/correct-full-postname/somemistakeword/, and since the only difference is a slash, they're considered equivalent. Some processing of the URL may also take place, and there is a canonical URL redirection routine which is quite complicated, and large in scope in WP Core.

As for why sitename.com/123/correct-full-postname/somemistakeword doesn't redirect to sitename.com/123/correct-full-postname, this is because they aren't the same, there is no post at sitename.com/123/correct-full-postname/somemistakeword. There are rewrite rules that would pick up sitename.com/123/correct-full-postname/2 aka page 2 of that post, and other specific endpoints such as sitename.com/123/correct-full-postname/feed etc

But if we implemented such a feature, it would not be so simple, for example, what would happen if we visit this page:


Would it:

  • Show you child page
  • Redirect you to parentpage
  • 404

As a sidenote, I have a blog post at:


If I remove the trailing slash, it redirects to the version with the trailing slash. If I append random characters to the end, I get a 404 as expected


I can't say for sure without seeing all of your current rewrite rules but you can inspect them with the following plugin: (working for me on 4.2.2)


My best guess is that your rewrite rules are instructing Wordpress to look for a page named "somemistakeword" that doesn't exist. The rewrite analyzer will give you insight into what Wordpress is actually seeing.

You can add new rewrite rules to cover your use case. https://codex.wordpress.org/Rewrite_API/add_rewrite_rule

There may be a plugin or two that make doing so easier though.

I hope this helps.

  • No, this is default... choose any random wordpress install and put a slash in the postname part of the url. Wordpress.com sites itself breaks. Jun 7 '15 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.