Using Google Custom Search and as part of it's configuration I specify a callback url on my site (e.g., www.example.com/search). I setup my page www.example.com/search as a Basic Page.

When someone searches for something they are taken to the url I specify and arbitrary query string parameters are appended (e.g., www.example.com/search?cx=partner&ie=UTF-8&q=dom&sa=Search&siteurl=www.example.com/search).

However this results in a page not found because Drupal appears to treat the entire request path as a url alias which it can't find.

How can I allow arbitrary query strings?


1 Answer 1


Drupal doesn't treat the query string as part of the URL alias, the problem is that your URL has the q parameter as part of it (q=dom).

Google obviously uses that for some purpose, but Drupal uses $_GET['q'] to determine the path of the page that should be shown. So when you visit a URL with q=dom in the query string, Drupal will try to find a page with the path dom...which obviously doesn't exist on your server.

Short of some crazy hacking of Drupal core (and probably dozens of contrib modules) I think the only way you're going to solve this is by somehow changing the original query string and removing the q parameter from it.

  • Thankfully Google's Custom Search Element Control API v2 has support for changing the query string parameter.
    – User
    Commented Nov 21, 2012 at 10:10
  • Core has an outstanding issue for this: Url Alias with Query String (D7) [#225112], drupal.org/node/225112#comment-11917892 Commented Feb 6, 2017 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.