Separate page for comments using permalinks and add_rewrite_rule

I have been at this for days now, going through plenty of answers here, guides on using .htaccess, guides on using add_rewrite_rule() within WordPress and examples throughout the web. I am not sure if there is a malfunction in my regex to detect the correct URL, or a disconnect between what I want to accomplish and what can be accomplished.

Basically, I am trying to separate comments from posts (or better yet, comments from content) by forcing them to a separate page “associated” with the content. So for example, http://localhost/wp/2011/02/25/hello-world-2/ is a post, and the comments for that post should appear at http://localhost/wp/2011/02/25/hello-world-2/comments/. Now, a “little bird” once said that this could be done with the following:

RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comments/?$ /index.php?year=$1&monthnum=$2&day=$3&name=$4&comments=1 [QSA,L] (seeing as I do not really need to work inside the /archives/ for my above example to work, I removed it), which I translated into this plugin:

Plugin Name: Gingah Permalink Rewrite
Plugin URI:
Description: Useful Permalink-structures, that required a plugin to work.
Version: 1.0
Author: Gingah
Author URI:

register_activation_hook( __FILE__, 'gingah_rewrite_activate' );
function gingah_rewrite_activate() {
register_deactivation_hook( __FILE__, 'gingah_rewrite_deactivate' );
function gingah_rewrite_deactivate() {
add_action('admin_init', 'gingah_rewrite');
function gingah_rewrite() {
    add_rewrite_rule( '^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comments/?$', '/index.php?year=$1&monthnum=$2&day=$3&name=$4&comments=1 [QSA,L]', 'top' );

(based on countless examples just like it, around the web)

This does, however, not work. Even though, visiting http://localhost/wp/2011/02/25/hello-world-2/?comments=1 does produce the expected result. So what is going wrong here?

Solutions Collecting From Web of "Separate page for comments using permalinks and add_rewrite_rule"

WordPress rewrite rules by default are no longer stored in the Apache configuration, but are handled by WordPress itself. This was probably not the case when that forum topic was written (5 years ago), but currently only “external” rules end up in the Apache configuration, all others are stored in the database and handled by the WP::parse_request() function.

This means you should leave off the Apache-specific parts in your add_rewrite_rule() call. The following code looks better:

    // The beginning `^` is added by WordPress
    // `$1` should be replaced with `$matches[1]`

When I tested this with my Rewrite analyzer plugin, I noticed that comments is not a standard query variable, so remember that you will have to handle that too.