Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#40836 closed defect (bug) (invalid)

add_rewrite_endpoint() creates sub directories after endpoint

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

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
6 years ago

  • Resolution set to invalid
  • Status changed from new to closed

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
6 years ago

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