how to create a redirection in rank math by using api

#556601
  • Resolved Anonymous
    Rank Math free

    Hi , i need to help for a problem
    I want to create redirection for some posts in php ( not manually ).
    rank math has redirection option manually and i used it.
    now , its my question : “how to create a rank math redirection by code and a function in php?”
    Do you have such api?

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    You can use wp_redirect() function to redirect URLs using your functions.php file.

    Here’s a sample code snippet for you:

    function rm_redirection(){
        $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    	if($url == 'YOUR URL HERE') {
    		wp_redirect(home_url());
    		exit;
    	}
    }
    add_action('init', 'rm_redirection');

    Here’s how you can add filters/hooks 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 1 replies (of 1 total)

The ticket ‘how to create a redirection in rank math by using api’ is closed to new replies.