How to redirect WordPress search query to Google CSE?

You can configure Google CSE to read the query variable (by default, it is q).

Then, in your WordPress’s .htaccess file, add these 2 lines

RewriteCond %{QUERY_STRING} ^s=(.*)$
RewriteRule ^ https://www.google.com/cse/publicurl?cx=xyz&q=%1 [R,L]

Here, “https://www.google.com/cse/publicurl?cx=xyz” is your CSE’s public URL or the webpage that contains the Google CSE result (with Javascript provided by Google CSE in the page).

Similar Posts

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *