Title: Programmatically Export Redirects
Last modified: October 30, 2018

---

# Programmatically Export Redirects

 *  Resolved [emaildano](https://wordpress.org/support/users/emaildano/)
 * (@emaildano)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/programmatically-export-redirects/)
 * Hey!
 * Is there a function/recommended way to programmatically export all redirects 
   to a JSON file?
 * I’m familiar with the REST API route to get these but it’s protected and there
   isn’t an example of how to access that route using a NONCE.
 * If there is a simple PHP function I can add to the plugin I’m developing that
   may work for now.
 * Thanks!
 * Ps: This is the WP Serverless Redirects plugins we discussed the other day. It’s
   not production ready yet but once I get this export function settled I can work
   on that release.
 * [https://github.com/getshifter/wp-serverless-redirects](https://github.com/getshifter/wp-serverless-redirects)

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

 *  Thread Starter [emaildano](https://wordpress.org/support/users/emaildano/)
 * (@emaildano)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/programmatically-export-redirects/#post-10834227)
 * The closest thing I could find was this but not sure how to use it.
 * \`
    $redirects = new Redirection_Api_Export(); $redirects->route_export(); `
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/programmatically-export-redirects/#post-10844427)
 * If you are accessing the REST API internally (i.e. your code is running in WordPress
   on the same server) then you can call it directly without needing authentication–
   see [https://developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/#can-i-make%c2%a0api-requests%c2%a0from-php-within-a-plugin](https://developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/#can-i-make%c2%a0api-requests%c2%a0from-php-within-a-plugin)
 * You only need authentication if you accessing it from JavaScript or another server,
   at which point you can look at [https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/)
 *  Thread Starter [emaildano](https://wordpress.org/support/users/emaildano/)
 * (@emaildano)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/programmatically-export-redirects/#post-10876641)
 * Perfect, thank you!

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

The topic ‘Programmatically Export Redirects’ is closed to new replies.

 * ![](https://ps.w.org/redirection/assets/icon-256x256.jpg?rev=983639)
 * [Redirection](https://wordpress.org/plugins/redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redirection/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [emaildano](https://wordpress.org/support/users/emaildano/)
 * Last activity: [7 years, 6 months ago](https://wordpress.org/support/topic/programmatically-export-redirects/#post-10876641)
 * Status: resolved