Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

404 if search.php?query=blabla has no results

         

dirkules

2:00 pm on Jan 26, 2012 (gmt 0)

10+ Year Member



Hey guys, I have the search on my site working like search.example.com/search.php?q=john+miller&l=new+york
and for SEO this request is redirected (302) to: search.example.com/new-york/john-miller

My burning question from the SEO point of view is: can I use a 404 status in my header on pages with no results like .../search.php?q=jsdkh&l=lkjdsfk? and should I have it redirect to /lkjdsfk/jsdkh if I do show a 404?

A big issue here could be search.php (with its destination/redirected pages) being registered as a 404 if there's no results.

Or should I just send a status 200 with a 'noindex' if there are no results on the search page? I'm sure you understand I don't want those no-result-pages indexed by Google & Co..

g1smd

8:50 pm on Jan 26, 2012 (gmt 0)

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



When there are no results, 404 is the correct response.

You can still send a page of code and human readable content for the visitor to either search again or click to another page.

lucy24

9:52 pm on Jan 26, 2012 (gmt 0)

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



Pages with parameters won't show up as 404 unless you have told gwt to ignore all parameters. You're doing the exactly right thing by not sending people (or robots) to nonexistent pages.

Custom 404 pages are for humans, so that's where you put the "I'm sorry, but..." stuff.

g1smd

10:01 pm on Jan 26, 2012 (gmt 0)

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



can I use a 404 status in my header on pages with no results like .../search.php?q=jsdkh&l=lkjdsfk? and should I have it redirect to /lkjdsfk/jsdkh if I do show a 404?

Yes, you should return 404 status for those queries.

No you should not redirect. A redirect will return 301 or 302 and will not return the required 404.

dirkules

10:31 am on Jan 30, 2012 (gmt 0)

10+ Year Member



No you should not redirect. A redirect will return 301 or 302 and will not return the required 404.


Well that's one thing I want to know. Will search.php be listed as 404 if there are no results or will the "page" (seo-friendly url) I redirect to? I'm just afraid that if search?q=blabla will get listed 404 the same will happen to search.php?q=resultlist

and I would have the destination (url friendly) page send a 404, after it was being redirected to.

lucy24

11:00 am on Jan 30, 2012 (gmt 0)

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



Wait a minute. Which pages are the search engines crawling? The ones with parameters, or the ones with pretty urls? They should never even be able to see the behind-the-scenes version.

Go off and search for your site by name. What kinds of pages come up?

It's an abiding mystery to me how g### even finds all those search-results pages to index, unless the internet is full of people posting links to them. Last I heard, the googlebot wasn't going around feeding questions into local searches. Hm. Sounds like the kind of thing it would do if it could-- and it would do it precisely to see if a garbage search results in the creation of a garbage page.

tedster

4:41 pm on Jan 30, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First thing to note is that the query string creates a unique URL - so search.php is not considered 404 just because search.php?param=foo returns a 404.

Last I heard, the googlebot wasn't going around feeding questions into local searches.

Ah, but they are. Members here first noticed it in 2007:
Google indexing large volumes of (unlinked?) dynamic pages [webmasterworld.com]
Google is indexing site search results pages [webmasterworld.com]

...and about a year later it was confirmed officially in the Google Blog article Crawling through HTML forms [googlewebmastercentral.blogspot.com]

Since then, googlebot has been seen plugging in all manner of keywords into a query string even when there is no HTML form, just sort of kicking the tires, as it were.

enigma1

12:02 pm on Feb 1, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The thing is if you need to expose some of the pages to spiders that perhaps a search brings up, then add regular link tags for bots to follow. But if you're concerned with the search form use a /POST method so the form won't be processed by robots.

If spiders find links generated from within your site due to the search or other methods leading to 404 or 302 etc, then you may get soft 404 errors in your gwt. And it means the site has problems which you need to fix. Every internal link you expose from within your site must point to a page returning 200 OK. And because Google processes /GET forms to find links you need to either convert them to /POST or use some js or make sure the search form returns valid pages.