First you need to find these lines in the ezSearch.cshtml. probably in line 285
@helper RenderNoResults(SearchViewModel model){
<div class="ezsearch-no-results"> <p>@FormatHtml(GetDictionaryValue("[ezSearch] No Results", "No results found for search term <strong>{0}</strong>."), model.SearchTerm)</p> }
</div> }
To these lines of code you need to add Response.StatusCode = 404; so the final code will look like this
Hope this does what you are after.
@helper RenderNoResults(SearchViewModel model){
<div class="ezsearch-no-results"> <p>@FormatHtml(GetDictionaryValue("[ezSearch] No Results", "No results found for search term <strong>{0}</strong>."), model.SearchTerm)</p>
May I ask why you want to show a 404 if a search result is not found?
Wouldn't it be nicer to track 0 results using Google Analytics and then figure out what people are searching for, which does not show any results? This can be really valuable knowledge and be an important part for optimizing content and SEO etc.
Search listing no results should show 404 error status code.
Hi all,
How can accomplish that when the ezSearch find that no results were found, output a 404 error status code (Not Found)?
Thank you in advance.
Kind Regards
Hi Simon,
I think you can do it like this:
First you need to find these lines in the ezSearch.cshtml. probably in line 285
To these lines of code you need to add Response.StatusCode = 404; so the final code will look like this
Hope this does what you are after.
/Dennis
Hi Simon
May I ask why you want to show a 404 if a search result is not found?
Wouldn't it be nicer to track 0 results using Google Analytics and then figure out what people are searching for, which does not show any results? This can be really valuable knowledge and be an important part for optimizing content and SEO etc.
Just my 2 cents :)
/Jan
is working on a reply...