Is this plugin compatible with a reverse proxy setup?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Is this plugin compatible with a reverse proxy setup?

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 weeks, 1 day ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #39312
    shaylang
    shaylang
    Participant

    We are currently using a reverse proxy on our site. Our CMS url is cms.netpayadvance.com but visitors come to netpayadvance.com

    The search bar is implemented on our Personal Finance Blog page. The search results show up perfectly fine on the cms.netpayadvance URL, but since visitors are only seeing netpayadvance.com, they’re not seeing the live search results and when actually searching for a keyword, the search bar redirects to our cms.netpayadvance.com link instead of netpayadvance.com

    Is there a way to get the search bar to pull up the results with the netpayadvance.com URL?

    #39319
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I believer the simplest solution to this is using a small custom code snippet to change the resutl URLs from the “cms.” subdomain to the main.

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter( 'asp_results', 'asp_custom_link_results', 10, 4 );
    add_filter( 'asp_noajax_results', 'asp_custom_link_results', 10, 4 );
    function asp_custom_link_results( $results, $search_id, $is_ajax, $args  ) {
    	// Array of original -> replacement links
    	$replace = array(
    		'cms.netpayadvance' => 'netpayadvance',
    	);
    
    	// --- DO NOT CHANGE ANYTHING BELOW ---
    	foreach ($results as $k=>&$r) {
    		$link = isset($r->link) ? $r->link : (isset($r->asp_guid) ? $r->asp_guid : '');
    		if ( $link == '' )
    		    continue;
    		$link = str_replace(array_keys($replace), array_values($replace), $link);
    
    		// Ajax results link
    		if ( isset($r->link) ) {
                $r->link = $link;
            }
    		// Results page link
    		if ( isset($r->asp_guid) ) {
                $r->asp_guid = $link;
            }
    	}
    
      return $results;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.