Cam
Cam

Reputation: 1

Google Custom Search Engine (cse) page not found in Drupal when using iframe hosting option

I'm using Google's custom search engine in a Drupal site. I am using the iframe hosting option. I get a Page Not Found error. Try it here: http://www.babymed.com/search. Search for "Pregnancy Calendar".

If I take a couple variables of the resulting url out of the query string and leave only these trailing the url: ?cx=partner-pub-8269249097348173%253Ayqmzpr-2cr9&cof=FORID%253A10

I still don't get any results. Any Google CSE experts out there?

Thanks!

Upvotes: 0

Views: 1358

Answers (3)

Jakob
Jakob

Reputation: 323

The problem is that Drupal interprets the q= parameter as a page name. I use a .htacces rewrite to hide the parameter on the search page from PHP, and therefore, from Drupal. Google CSE runs client-side and will still see the parameter:

RewriteRule ^search$ index.php?q=search [L]

Adjust the search page name ("search") as neccessary and insert the line at the top of the file. That's it. No module required.

Upvotes: 0

user113292
user113292

Reputation:

You can use the Google CSE module as jhuebsch mentioned, but the root of the problem is that Drupal depends on using the q GET parameter for determining what page to serve, while Google CSE uses it to determine what the search query is. So, what's occuring is the search query is being sent to Drupal, which obviously can't find the page you're requesting.

So, if you wanted to deal with it yourself, use Google CSE's as_q parameter, which was designed to deal with this problem. The Google CSE module incorporates this workaround.

Upvotes: 0

jhuebsch
jhuebsch

Reputation: 451

Are you using the Google CSE module, if not I strongly suggest it. By default Drupal and Google CSE both use the q GET variable which can causes problems. The module I linked to above takes care of that.

Upvotes: 2

Related Questions