>
function _ii404search_uri(){
$url = referer_uri();
// get host name from URL
preg_match("/^(http:\/\/)?([^\/]+)/i", $url, $matches);
$host = $matches[2];
preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
$domain = $matches[0];
$name = explode('.', $domain);
$engine = $name[0];
if ($engine == 'yahoo'){
//parse yahoo referers to get the query string.
return '';
}else if($engine == 'google'){
//parse google referer to get the query string.
//from q= to &
//strip + and -, use explode.
//http://junk?q=(capture)?
preg_match("/^(http:\/\/)?([^\/]+)(.*?q=)(.*?)&/i", $url, $matches);
$keys = $matches[4];
return implode(" ",explode('+', $keys));
//preg_match("/(http:\/\/)?([^\/]+)/i", $url, $matches);
}else
return '';
}
Above is code that I am working on, I need help with refining it and adding additional referers... Basically I find the 404 module not all that useful in most circumstances because the URL is not that often, unless you want it as such, that descriptive about content. The idea is that we read what the user was searching for at the search engine and then find that content... Hence a much more effective search is rendered for the missing content. There is a version of this module that can be found here for 4.6, probably also works with 4.7: http://drupal.etopian.net/files/ii404search.module.gz
Comments
Comment #1
larssg commentedThat sounds like a very good idea. I'll do some research to see if I can come up with a solution - it should be possible to base the keyword-detection on an array of search-engines containing domain and what key to look for in the querystring.
Comment #2
korayal commentedis there any progress about this work?
Comment #3
larssg commentedhecatomber: Yes, I have made progress and it's working very well. However, I've been "out of the loop" recently, so it's lying around on my laptop waiting to be cleaned-up and committed. I hope to do so soon.
Comment #4
forngren commentedBeta code for this is live in 5.x series http://drupal.org/node/128884
Comment #5
(not verified) commented