Форуми / Cotonti / Extensions / [Release] 404search

Redirect a 404 page to search plugin

GHengeveld
#1 15.10.2010 17:19
This plugin is meant to 'catch' broken URLs still listed in Google. If a 404 message comes up, this plugin checks for a referrer, and if that contains a search query (q=...) it redirects to the search plugin.

Installation:
  • Upload files to /plugins
  • Install through admin panel
  • Optionally: edit search plugin (see below)

» Download here

The plugin passes the Google query to the search plugin, but since the current search plugin doesn't support queries though GET, it won't show them. If you want them to show, you have to edit your search plugin:

In plugins/search/search.php, at line 29 you have this:
$sq = sed_import('sq','P','TXT',$cfg['plugin']['search']['maxsigns']);

Below that line, add this:
$q = sed_import('q','G','TXT',$cfg['plugin']['search']['maxsigns']);
if(!$sq && $q) $sq = $q;

Around line 39, you have:
$a = sed_import('a','P','ALP');

Below that, add this line:
if($q) $a = 'search';

In the future I may rewrite the search plugin to use GET instead of POST.

Added 2 hours 34 minutes later:

You can test it by running a Google search for "hyves mashup", which should return a link to "Project 3: Hyves Mashup" (www.ghengeveld.nl/weblog/p/29) at . This URL is dead, but will bring up the search. (Don't know how long Google will keep returning this result.)

Відредаговано: Koradhil (15.10.2010 20:11, 13 років тому)
ven7ura
#2 16.10.2010 00:23
Very nice plugin!

Will be a nice addition to one of my sites.
GHengeveld
#3 16.10.2010 00:28
It's a niche thing really, but since its tiny and simple there's no reason not to use it. :)
I only developed this because I recently changed my entire site structure (and URLs) and Google hasn't re-indexed everything so I'm still getting visitors ending up on 404 pages. I just wanted to give these visitors a way to still find what they were looking for, even though it requires one more click.
Kort
#4 16.10.2010 02:32
# ven7ura : Very nice plugin!
Will be a nice addition to one of my sites.
Boring replies do not affect download counters.
Hacking search plugin is not good, but SEO-wise the plugin idea is great. 404 redirects, however can be different (index or sitemap in instance), so why not give user a choice?
SED.by - создание сайтов, разработка плагинов и тем для Котонти
GHengeveld
#5 16.10.2010 04:01
Yes, it's good for SEO also. Actually it would be even better to do a search in the background, and redirect to the first result immediately, returning a 301 Moved Permanently. This will let Google know it has to change the URL it has for the page.
ven7ura
#6 16.10.2010 07:27
# Kort : Boring replies do not affect download counters.
Hacking search plugin is not good, but SEO-wise the plugin idea is great. 404 redirects, however can be different (index or sitemap in instance), so why not give user a choice?

Whats with the attitude!?

Anyways, the idea is great and I will be checking out for upgrades. Good Work.
aiwass
#7 30.01.2011 18:08
Could this be modified to that it searches Tags plugin instead of using Search plugin?
Take all that money that we spend on weapons and defences each year and instead spend it feeding and clothing and educating the poor of the world, which it would many times over, not one human being excluded, and we could explore space, together, both inner and outer, forever, in peace. - Bill Hicks

https://evlear.com
GHengeveld
#8 01.02.2011 18:59
Probably yes, but I think it would make more sense to modify the search plugin instead, which is actually on my to-do list for this week. I've written an Indexer plugin that indexes your site, storing all the words and their occurrences in a seperate database table. The new search plugin will get the option to search the site index rather than search the pages directly (which can be very slow). I will add support for searching tags as well.