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 6 months, 1 week ago.
- AuthorPosts
- September 16, 2022 at 6:58 pm #39312
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?
September 17, 2022 at 1:21 pm #39319Hi,
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.
Best,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; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.