Title: how can i add redirection using program
Last modified: December 7, 2021

---

# how can i add redirection using program

 *  Resolved [Byron Hasegawa](https://wordpress.org/support/users/byron222/)
 * (@byron222)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/how-can-i-add-redirection-using-program/)
 * i want to add redirections using some hook or filter in functions.php
 * how can i do this?

Viewing 1 replies (of 1 total)

 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * (@rankmathteam)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/how-can-i-add-redirection-using-program/#post-15143013)
 * Hello [@byron222](https://wordpress.org/support/users/byron222/),
 * Thank you for contacting the support.
 * Yes. You can use the `Redirection\DB:add` function to add the new redirections
   from the functions.php file:
    Code:
 *     ```
       \RankMath\Redirections\DB::add(
       				[
       					'url_to'      => $redirection['url_to'],
       					'sources'     => $sources,
       					'header_code' => $redirection['header_code'],
       					'hits'        => $redirection['hits'],
       					'created'     => $redirection['created'],
       					'updated'     => $redirection['updated'],
       				]
       			);
       ```
   
 * Reference code:
    [https://github.com/rankmath/seo-by-rank-math/blob/master/includes/admin/class-import-export.php#L464-L485](https://github.com/rankmath/seo-by-rank-math/blob/master/includes/admin/class-import-export.php#L464-L485)
 * This code is from the Import file which we use to import the Redirection rules
   from other plugins.
 * Hope that helps.

Viewing 1 replies (of 1 total)

The topic ‘how can i add redirection using program’ is closed to new replies.

 * ![](https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=3438330)
 * [Rank Math SEO – AI SEO Tools to Dominate SEO Rankings](https://wordpress.org/plugins/seo-by-rank-math/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/seo-by-rank-math/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/seo-by-rank-math/)
 * [Active Topics](https://wordpress.org/support/plugin/seo-by-rank-math/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seo-by-rank-math/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seo-by-rank-math/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/how-can-i-add-redirection-using-program/#post-15143013)
 * Status: resolved