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!
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.
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.
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.
精彩评论