• The redirection from old to new slug made by WordPress takes account on child paths like:

    example.com/old-poat-slug/some_attachment to example.com/new-poat-slug/some_attachment
    example.com/old-poat-slug/amp to example.com/new-poat-slug/amp

    Could you consider to add this functionality to your plugin or give the option to handle this by WordPress itself?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author John Godley

    (@johnny5)

    Have you looked at the URL monitoring option here:

    https://redirection.me/support/options/

    It should handle this situation.

    Thread Starter cybmeta

    (@cybmeta)

    Yes, I have that option activated. But it doesn’t work for child paths. I see there is another option to asociate a child path, i.e. “/amp”. But what if it needs to be dynamic or if there are more than one, i.e. for amp and for all attachements of the parent post?

    This situations are handled by WordPress, why your plugin replace this core functionality? Is there any reason?

    Plugin Author John Godley

    (@johnny5)

    I’m not entirely sure what the question is. The plugin changes WordPress core redirections as it clashes with the plugin.

    Thread Starter cybmeta

    (@cybmeta)

    You have one post that change the slug:

    example.com/old-post-slug to example.com/new-post-slug

    Then you need to redirect
    example.com/old-post-slug/amp to example.com/new-post-slug/amp
    AND
    example.com/old-post-slug/some_attachmet to example.com/new-post-slug/some_attachmet
    AND
    example.com/old-post-slug/other_attachmet to example.com/new-post-slug/other_attachmet
    AND
    example.com/old-post-slug/feed to example.com/new-post-slug/feed
    AND so on

    I hope you understand now what I mean.

    Can your plugin automatically redirect a modified post and all its children paths?

    I’m actually handling this by adding a regex redirection, post by post, but it should be handled by your plugin automatically the same way it is handled by WordPress core, otherwise I see a broken core functionality when your plugin is active.

    Thread Starter cybmeta

    (@cybmeta)

    I’ve made a very quick test modifying ‘redirection/modules/wordpress.php`, lines 26-30, from:

    add_action( 'template_redirect', array( $this, 'template_redirect' ) );
    
    // Remove WordPress 2.3 redirection
    remove_action( 'template_redirect', 'wp_old_slug_redirect' );

    To:

    add_action( 'template_redirect', array( $this, 'template_redirect' ), 11 );
    
    // Remove WordPress 2.3 redirection
    // remove_action( 'template_redirect', 'wp_old_slug_redirect' );

    By hooking your functions with priority of 11 in template_redirect, they will be triggered after the core wp_old_slug_redirect() function (it is hooked with a default priority of 10), it seems that the core old slug redirection works as expected and your plugin still work as expected too, have you tried this? Could you?

    Plugin Author John Godley

    (@johnny5)

    Thanks, but that doesn’t really do much as it’s only used for detecting 404s. I will look at attachment redirects separately.

    Thread Starter cybmeta

    (@cybmeta)

    Yes, but they are detected after WordPress has handled them and has performed the old-slug redirection itself, and so your plugin doesn’t break it because it enters in the scene only in case of “true” 404s that WordPress couldn’t handle itself and not before.

    I hope it makes sense.

    I’m still testing that change and still everything seems to work as expected, please, give a try. I really think you should leave the core functionality untouched unless you are going to introduce a improvement or something different from the core, which doesn’t seem to be the case. Correct me if I’m wrong.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Old-to-new slug redirection doesn’t work in child paths’ is closed to new replies.