Forum Moderators: phranque

Message Too Old, No Replies

How to exclude specific phrases from search results

         

perlgerl

3:02 pm on Jul 16, 2010 (gmt 0)

10+ Year Member



I am new to WebmasterWorld and desperately need assistance with a problem I am having and hope to find a solution here.

When I conduct a search for Eg. 'blue dogs', I receive several search results, all of which I want to exclude.
I do not want any search results if someone searches for that specific term.
Is there a way to exclude the search results I want by including a line in my htaccess file prohibiting results for "blue dogs" and just come back with "search results do not exist" ?

Is this even possible or must I find a way to do this in my dogs.pl file instead?

My htaccess:

RewriteEngine on
RewriteBase /furryfriends
RewriteRule kitty_friends/(.*) cats.pl?$1
RewriteRule doggie_friends/(.*) dogs.pl?$1

Thank you!

wilderness

5:46 pm on Jul 16, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The only way to accomplish this is based upon referrals, however referral based rewrites have many limitations.

jdMorgan

2:01 am on Jul 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"Conduct a search" where? -- On your own site using its own search facility, or in Google/Yahoo/Bing/Ask etc.?

If you don't want search engines to fetch a page, use robots.txt to Disallow them.

If you don't want search engines to list a page, use an on-page <meta name="robots" content="noindex"> tag, and do not disallow search engines from fetching the page.

Jim

perlgerl

10:18 am on Jul 17, 2010 (gmt 0)

10+ Year Member



Yes, sorry on my own site. I'm a newb.

Is it possible to do?

Thanks.

mack

3:54 pm on Jul 17, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



This will depend greatly on the search software you are running to provide the search. A simplistic way of doing this would be to analyze the search query server side, before it goes to your actual search script. If the search query meets a certain criteria that you don't want to serve results for simple point the user to something else as opposed to the search script.

Mack.

perlgerl

5:40 pm on Jul 17, 2010 (gmt 0)

10+ Year Member



Thanks, Mack.

This is my form:


##############################################################
$lnm = $FORM{'lastname'};
if (($lnm ne "") and ($lnm !~ /^[\w]{3,30}$/g)) { showerror("search term invalid"); }
$name = $FORM{'name'};
if ($name eq "") {
$datain = "$ENV{'QUERY_STRING'}";
$datain =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$datain =~ s/\cM//g;# delete ^M's
$datain =~ s/\0//g;
$name = "$datain";
}
$name =~ s/([\\`\\\|<>\(\)\[\]\{\}\$\n\r])/\\$1/g; # the great escape
if (length($name) < 3) { showerror("you must enter a word of at least 3 letters"); }
if ($name !~ /^[\w\s]{3,30}$/g) { showerror("search term invalid"); }

Can I enter another if statement here to come back as "search term invalid" if anyone types in blue dogs or purple rhinos or yellow monkeys?

Thank you all for your help.

mack

8:00 pm on Jul 17, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



somethign like...

if ($name=="bad term here")
{
showerror("That search term is not allowed.")
}

Mack.

g1smd

8:43 pm on Jul 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'd probably go for:

showerror("No results found.")

mack

9:18 pm on Jul 17, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Good point...

Also if you have multiple terms...

if ($name=="bad term here") || ($name=="another term here") || ($name=="some term here")
{
showerror("your error message")
}

perlgerl

10:31 pm on Jul 17, 2010 (gmt 0)

10+ Year Member



It isn't working and I am getting my "handle errors nicely" message.

Dang. Any ideas?

Thanks for your help.