How to redirect search query to subdomain

Posted in: Newspaper
Post count: 13

Hi we need to redirect all search queries to a “search” subdomain.

The current newspaper functionality will redirect query for local dentist to

https://domain.com/?s=local+dentist

and we need it to go to the “search” subdomain along with modifying the url string to match /serp?=[query] so that a search of local dentist on domain.com would go to:

https://search.domain.com/serp?q=local+dentist

How can this be done? Ideally within the theme panel but can also modify function file with your suggested code to accomplish this

Thanks for all your help!

Post count: 21065

Hello!

I think the easiest method is to find a plugin to redirect the links. I do not recommend interfering with the code. Also, you can disable the search feature in our theme and use a search plugin.

Thank you!

Post count: 13

Hi Bettina thanks for the quick reply

Unfortunately most search plugins I’ve found are to host the search results page, change styles, etc similar to newspaper’s functionality. Do you have one in mind to accomplish the OP question?

I need the functionality described in the opening post because I am working with an advertising partner that is going to host the search results page and needs the query request to be forwarded in that exact manner so instead of the results page going to

https://domain.com/?s=local+dentist

we need it to go to the “search” subdomain along with modifying the url string to match /serp?=[query] so that a search of local dentist on domain.com would go to:

https://search.domain.com/serp?q=local+dentist

I understand its not best practice but can you point me in a different direction to accomplish this?

Post count: 9544

Simplest course, since not theme related in any way, is to hire developer for custom plugin

— or, what I’d try is setting up search on the sub domain, then insert a search box on your main site that points to the search plugin on the target site. Meaning main site has simple HTML form element that targets the plugin on the sub domain doing the search.

(I don’t work here.)

Post count: 13

Hey Chris, thanks for the reply! The search results page is hosted already by a partner so all I need is for the user to to be redirected properly to the “search” subdomain with a slightly modified string /serp?=[query] so that a search of local dentist on domain.com would go to:
https://search.domain.com/serp?q=local+dentist
which at least partially appears to be controlled by searchform.php
Figured I could fix myself without the need of a developer this weekend but will probably end up needing one 🙂

Viewing 5 posts - 1 through 5 (of 5 total)
The forum ‘Newspaper’ is closed to new topics and replies.