Title: Redirect Loop
Last modified: June 23, 2018

---

# Redirect Loop

 *  [unaomnia](https://wordpress.org/support/users/unaomnia/)
 * (@unaomnia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/redirect-loop-88/)
 * I have made a rewrite code and am getting a redirect loop:
 * add_action( ‘init’, ‘wpse16902_init’ );
    function wpse16902_init() { $GLOBALS[‘
   wp_rewrite’]->use_verbose_page_rules = true; }
 * add_filter( ‘page_rewrite_rules’, ‘wpse16902_collect_page_rewrite_rules’ );
    
   function wpse16902_collect_page_rewrite_rules( $page_rewrite_rules ) { $GLOBALS[‘
   wpse16902_page_rewrite_rules’] = $page_rewrite_rules; return array(); }
 * add_filter( ‘rewrite_rules_array’, ‘wspe16902_prepend_page_rewrite_rules’ );
   
   function wspe16902_prepend_page_rewrite_rules( $rewrite_rules ) { return $GLOBALS[‘
   wpse16902_page_rewrite_rules’] + $rewrite_rules; }
 * function wpse_56769_post_link( $permalink, $post ) {
 *  $terms = wp_get_post_terms( $post->ID, ‘resource_type’ );
    if ( ! empty( $terms)&&!
   is_wp_error( $terms ) ) { $thisTerm = current( $terms )->slug; $permalink = str_replace(‘%
   resource_type%’, $thisTerm, $permalink ); }
 *  $iterms = wp_get_post_terms( $post->ID, ‘item_type’ );
    if ( ! empty( $iterms)&&!
   is_wp_error( $iterms ) ) { $thisTerm = current( $iterms )->slug; $permalink =
   str_replace( ‘%item_type%’, $thisTerm, $permalink ); }
 *  $jrterms = wp_get_post_terms( $post->ID, ‘jnyc_resource_type’ );
    if ( ! empty(
   $jrterms ) && ! is_wp_error( $jrterms ) ) { $thisTerm = current( $jrterms )->
   slug; $thisTerm = ‘jugglenyc/’ . $thisTerm; //this is the domain mapping part
   $permalink = str_replace( ‘%jnyc_resource_type%’, $thisTerm, $permalink ); }
 *  // if(get_field( ‘permalink’, $post->ID )){
    // $thisPerma = get_field( ‘permalink’,
   $post->ID ); // $thisPerma = ‘jugglenyc/’ . $thisPerma; // $permalink = str_replace(‘%
   perma%’, $thisPerma, $permalink ); // }
 *  return $permalink;
 * }
    add_filter( ‘post_type_link’, ‘wpse_56769_post_link’, 10, 2 );
 * function wpse_56769_rewrite_verbose_page_rules( $pass_through = NULL ) {
 *  $permastruct = $GLOBALS[ ‘wp_rewrite’ ]->permalink_structure;
    $permastruct 
   = trim( $permastruct, ‘/%’ ); if ( 0 !== strpos( $permastruct, ‘resource_type%’)
   || 0 !== strpos( $permastruct, ‘item_type%’ )) { return $pass_through; }
 *  $GLOBALS[ ‘wp_rewrite’ ]->use_verbose_page_rules = TRUE;
    return $pass_through;}
   add_filter( ‘page_rewrite_rules’, ‘wpse_56769_rewrite_verbose_page_rules’, PHP_INT_MAX);
   add_filter( ‘do_parse_request’, ‘wpse_56769_rewrite_verbose_page_rules’, PHP_INT_MAX);
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fredirect-loop-88%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Plugin Author [matthias.wagner](https://wordpress.org/support/users/matthiaswagner/)
 * (@matthiaswagner)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/redirect-loop-88/#post-10462180)
 * [@unaomnia](https://wordpress.org/support/users/unaomnia/), sorry for the late
   response 😉
 * i’m afraid we really can not give support for your custom code. of course feel
   free to use the forum to discuss things with other users, but we will only be
   here for problems with the core functionality…
 * good luck,
    matt

Viewing 1 replies (of 1 total)

The topic ‘Redirect Loop’ is closed to new replies.

 * ![](https://ps.w.org/multiple-domain-mapping-on-single-site/assets/icon-256x256.
   png?rev=1595238)
 * [Multiple Domain Mapping on Single Site](https://wordpress.org/plugins/multiple-domain-mapping-on-single-site/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/multiple-domain-mapping-on-single-site/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/multiple-domain-mapping-on-single-site/)
 * [Active Topics](https://wordpress.org/support/plugin/multiple-domain-mapping-on-single-site/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multiple-domain-mapping-on-single-site/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multiple-domain-mapping-on-single-site/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [matthias.wagner](https://wordpress.org/support/users/matthiaswagner/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/redirect-loop-88/#post-10462180)
 * Status: not a support question