Redirections Priority

#648393
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    In this case, you’ll have to create two separate Exact type redirections. For only the /tag/ URL, you can set the redirection like this:

    Source: tag/
    Match: Exact
    Destination: /
    

    And for the /tag/seo/URL, you’ll have to create another redirection like the following one:

    Source: tag/seo/
    Match: Exact
    Destination: your_destination_url
    

    Please make sure to replace your_destination_url with the actual URL.

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    Ray
    Rank Math free

    Thank you for your reply.
    I am sorry that I didn’t make it clear,
    I forgot to tell that I want all link start with “/tag” to be redirected, not just “/tag”, should be as follow:

    #1 https://example.com/tag/* –> https://example.com/

    Thus I choose “starts with” :

    Source: tag/
    Match: Starts with
    Destination: /

    It worked but it also redirect all link that start with “tag”, including “/tag/seo/”.

    That’s why I am looking for a Redirections Priority. Thank you.

    Hello,

    We deeply apologize for the unexpected delay in response. Your previous reply seems to have been stuck in our drafts section for some reason.

    If you only want to redirect the URLs starting with /tag/ to your homepage but not the URLs with /tag/seo/ then you can use the following filter on your website and see if that works for you.

    function custom_redirect_tags() {
        $request_url = $_SERVER['REQUEST_URI'];
    
        if (strpos($request_url, '/tag') === 0 && strpos($request_url, '/tag/seo') !== 0 ) {
            wp_redirect(home_url(), 301);
            exit();
        }
    }
    
    add_action('template_redirect', 'custom_redirect_tags');
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Redirections Priority’ is closed to new replies.