How does WP handle multiple matching rewrite rules?

Here is my url to a custom type :

http://host/movie/my-slug

When I go to this link, I’m redirected to

Read More
http://host/movie/my-slug/?post_type=movie

which results in a 404 error.

I use Rewrite Rule Inspector wordpress plugin for listing the matching rewrite rules.

It appears that my url matches three rules : (regex new-url source)

  • movie/([^/]+)(/[0-9]+)?/?$ index.php?post_type=movie&name=$matches[1]&page=$matches[2] movie
  • (.?.+?)(/[0-9]+)?/?$ index.php?pagename=$matches[1]&page=$matches[2] page
  • [^/]+/([^/]+)/?$ index.php?attachment=$matches[1] post

Witch one WordPress will choose for resolving my url ?
Why do I have a 404 error ?

Related posts

Leave a Reply

1 comment

  1. I think it matches the first one in the array. So you enter specific rules above more general ones. In your case it should be matching the movie rule if it has a lower array index number than the other ones.