I have module where I'm creating a custom path in hook_menu. When the user visits this page, they are supposed to be redirected to another site, with GET query parameters attached to the redirect URL. So for instance, if they visit http://mysite.com/site-search?query=blah
, we are supposed to redirect them to http://othersite.com/different-path?query=blah
.
However, we have clean URLs enabled; while I can hit the page http://mysite.com/site-search
, it gives a page not found when I try to hit http://mysite.com/site-search?query=blah
.
The requested page "/site-search?query=blah" could not be found.
I tried adding another path for site-search/%
, just to get that extra part of the URL, but that didn't work either.
Am I able to get the URL parameters while using clean URLs?
Edit: Here's the code:
function my_redirect_menu() {
$items['site_search'] = array(
'page callback' => 'my_redirect_redirect',
'access callback' => TRUE,
);
// testing to see if this will allow me to capture get parameters
// in the form http://site.com/site_search/q=blah
$items['site_search/%'] = array(
'page callback' => 'my_redirect_redirect',
'access callback' => TRUE,
);
return $items;
}
function my_redirect_redirect() {
// see if we can get the get paramters
return "<pre>" . print_r($_SERVER,1) . "</pre>";
}
Edit 2 In my example, I transcribed the query string in correctly. It looks like it's a conflict between drupal wanting to use ?q=
for its menu routing, and our search host URLs also using ?q=
for their queries. If I do query=blah
, I am able to hit the page.
?q=
.