Opened 4 months ago
Closed 21 hours ago
#62962 closed defect (bug) (duplicate)
Comments feed for a non-existent URL
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Feeds | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Hello.
Normally, a comments feed has a URL like http://example.com/comments/feed/
, but even if you access a non-existent URL like http://example.com/abcdefg/feed/
, the XML will be displayed.
is_comment_feed()
works on this unknown URL, so it's clear that a comment feed is involved.
The XML displayed when the unknown URL is accessed also contains the word Comments, so it's definitely related to a comments feed.
XML excerpt
<title> Comments on: </title> <atom:link href="https://192.168.100.100/abcdefg/feed/" rel="self" type="application/rss+xml" /> <link>https://192.168.100.100</link> <description>TEST</description> <lastBuildDate>Wed, 12 Feb 2025 10:20:24 +0000</lastBuildDate> <sy:updatePeriod> hourly </sy:updatePeriod> <sy:updateFrequency> 1 </sy:updateFrequency> <generator>https://wordpress.org/?v=6.7.2</generator>
Change History (4)
#2
@
4 months ago
The problem is that it doesn't return an 404error when accessing a non-existent URL.
#3
@
4 months ago
A simple solution
add_action( 'template_redirect', function() {
if ( is_comment_feed() && esc_url_raw( site_url().$_SERVER['REQUEST_URI'] ) !== get_feed_link( 'comments_rss2' ) ) {
wp_die( '', '', array( 'response' => 404 ) );
}
} );
#4
@
21 hours ago
- Description modified (diff)
- Keywords reporter-feedback removed
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
- Summary changed from Comments feed to Comments feed for a non-existent URL
- Version 6.7.2 deleted
This seems to be the same as #30210. Please follow that ticket.
Note: See
TracTickets for help on using
tickets.
hi, @manbo , can you elaborate a bit what is the issue is here exactly?