Google CSE Module URL Rewrite

I found a great tip regarding fully integrating the Google CSE module with the rest of your Drupal installation.

Basically, the tip I found to be really useful was the rewrite rules for the Google CSE search itself. Since Drupal comes with this built-in search module which is easily accessible at http://kerola.nu/search/your-terms-here, it’s really great to use Apache URL rewrite and redirect users from that Drupal search (which I think isn’t really that good) to the Google CSE result page. The only real change from the original page is the last line of the code, which sort of sums things up and enables the user to search directly from “search/your-terms-here”. Take a look at the code below!

In your .htaccess file, add the following lines:

RewriteRule ^search$ /search/google [R=301,NC,L]
RewriteRule ^search/node$ /search/google [R=301,NC,L]
RewriteRule ^search/node/(.*)$ /search/google?query=$1 [R=301,NC,L]
RewriteRule ^search/taxonomy_search$ /search/google [R=301,NC,L]
RewriteRule ^search/taxonomy_search/(.*)$ /search/google?query=$1 [R=301,NC,L]
RewriteRule ^search/((?!google).*)$ /search/google?query=$1 [R=301,NC,L]

Idea from http://www.mc-kenna.com/general/2008/12/tips-for-google-cse-plugin-for-d…
Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>