Back to top

Google On Site Search - Only useful if you don't already use URL Parameters

I read the Inside AdSense Blog because monetization is FUN! Today I woke up to see that they now have a search box that will give results right inside your own page which is a great step beyond their previous effort (the previous effort allowed you to do some basic theming of the results page...pretty useless). So, I got all excited and hooked it up on and if you try it out what you'll find is that the search code and Drupal get mad at each other.

A Little History

Drupal, like many web applications, originally used URL parameters to create its URLs. Things like ?q=node/3 or ?q=admin let the system know that the user is requesting the "node/3" page or the "admin" page. Over the years people figured out fancy ways to make URLs work without the ?q= but Drupal still supports this notation in case your configuration doesn't allow the rewriting magic necessary. It's also handy for when you recompile apache and forget rewrite and your site breaks - then you can still get into ?q=admin/settings and fix stuff.

The Google vs. Drupal conflict

The way this becomes a problem is because Google's search expects to be able to use the "q=" parameter and it creates URLs like which then confuses Drupal into thinking that I'm asking for a page named term which doesn't exist. The funny thing is that when you do a google search for a path that actually exists and is available (like node/198) then Drupal returns that page quite nicely.

I'm not sure what the fix is. I can imagine one solution being to use a more specific url parameter than "q" like "dq" but I doubt we're going to get the millions of people using Drupal to change. I can also imagine a setting in Drupal for "no really, ignore, I only want clean URLs so please ignore any q= in the URL parameters" but that doesn't feel right. Of course, part of the reason I'm writing about this is a little lazyweb plea for someone with a better idea on how to fix it.

Even more likely - no solution. This doesn't seem like that big of a deal so just move on...

People Involved: 


I, too, was happy to see

I, too, was happy to see Google release this. Sad to hear it's incompatible with Drupal. Doesn't seem too far-fetched to have Drupal ignore the q param when clean URLs are enabled, except that it tends to be helfpul when you turn on clean URLs, it errors, and you need to manually get back to certain pages. Perhaps Google themselves will address this somehow...

is a problem

i think there is a problem here. i read the google gdata spec and there is a conflict with q= param there too. i think dq is a reasonable solution ... but yeah, i don't see much uproar about this. maybe later.

A workaround for Drupal

I found a workaround to this problem. It is describet at
and implemented in one of my websites at "" (It is an italian web site, sorry!)


Thanks Valerio - this is an interesting workaround. As you point out it's definitely a workaround and not a solution, but it's great to see that there is a solution if someone "really" neeeds one.