Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#40836 closed defect (bug) (invalid)

add_rewrite_endpoint() creates sub directories after endpoint

Reported by: henry.wright Owned by:
Priority: normal Milestone:
Component: Rewrite Rules Version:
Severity: normal Keywords:
Cc: Focuses:

Description

Adding an endpoint with add_rewrite_endpoint() seems to also create sub directories after that endpoint. For example:

// Add query var.
add_filter( 'query_vars', function( $vars ) {
    $vars[] = 'my-endpoint';
    return $vars;
} );

// Add endpoint.
add_action( 'init', function() {
    add_rewrite_endpoint( 'my-endpoint', EP_AUTHORS );
} );

I can now visit:

  • example.com/author/my-endpoint
  • example.com/author/my-endpoint/random
  • example.com/author/my-endpoint/anything-here

Is this expected?

I believe the following should return a 404:

  • example.com/author/my-endpoint/random
  • example.com/author/my-endpoint/anything-here

Change History (2)

#1 @henry.wright
9 years ago

  • Resolutioninvalid
  • Status newclosed

After researching this issue some more I see this is how add_rewrite_endpoint() is intended to work.

Anything after my-endpoint/ is matched by the rewrite rule and is therefore used in the query string.

Closing.

#2 @SergeyBiryukov
9 years ago

  • Milestone Awaiting Review
Note: See TracTickets for help on using tickets.