Search Results Page may be different per Search Scope

This blog posting applies to Microsoft Office SharePoint Server 2007.

Microsoft Office SharePoint Server 2007 provides two categories of search scopes: Custom and Contextual.

  • Custom scopes:
    • “All Sites”
    • “People”
    • The custom search scopes created via the search or site admin pages
  • Contextual scopes:
    • “This Site”
    • “This List”


Search behaves slightly differently between these categories.  Specifically, there are two pages on which search results are displayed, one for each category.  The page for Custom scope results is the most familiar: it’s the one that offers custom scopes and properties available via Advanced Search.  The page for Contextual scope results is much simpler: there are no best bets, high confidence results, advanced search link nor search tabs.  This page is also customizable, but is done at the level of a web designer or farm administrator, not in the same way as the one for Custom scopes, which can usually be customized pretty easily by individual site administrators.


Also, the search results page that can be configured on the Search Settings page affects Custom scope results, and defaults to /SearchCenter/Pages.  This setting has no effect on Contextual scope results, which always go to /_layouts/osssearchresults.aspx for MOSS installations (for WSS-only, it is /_layouts/searchresults.aspx).



When people use the “This Site” or “This List” scope to search, the search engine will perform as it always does, but the results will be shown on a different page and the users may be confused by missing functionality on that page.



The two scope categories are implemented by two different products: contextual scopes are provided by the WSS platform, while custom scopes are provided by the MOSS product running on that platform.  This is not an excuse, merely an explanation.  It could be argued that it's not so bad for these results pages to differ when someone is searching This Site or This List, because their focus is narrower and they don’t need the advanced results as they do when searching much broader scopes.  But users naturally express confusion over why the results are organized differently.





Jan Geisbaur commented that he found a pretty simple workaround to redirect to a custom search results page:


1. Create a new aspx through sharepoint designer (named custom-search.aspx)
2. Copy code from osssearchresults.aspx to custom-search.aspx, and modify the masterpage
   in custom-search.aspx
3. make a backup of osssearchresults.aspx and replace code with the following javascript:

As you can see this takes the parameters from the search box and passes it to custom-search.aspx

Remember when you make the special osssearchresults.aspx file, it is unghosted.  This means you should create a feature that will install this unghosted file to current site collections, enabling you to deploy it.






Other Options

The following were original ideas for changing this behavior to make it more consistent.

  1. Create a new search box control that builds a list of scopes that know how to redirect contextual scopes to the same results page as Custom scopes.  Note that it will probably be easier to build a control that does not inherit from the search box control, because the job of this control is very simple and it would be extra effort to understand and override the base behavior.  Not an option; the result page is hardcoded and must be overridden after the query.
  2. Convert the contextual search results page to a redirect to the custom search results page.  The key to understanding this is that the actual search is executed by the SearchCoreResults control, not the SearchBox control, so it's just a matter of making sure the search term data gets to the right results page.  This option is described above as the workaround.
  3. Customize the contextual search results page to work more like the custom search results page.  Challenge here is this page is more difficult to configure, and it may not be possible to fully match functionality.  This  is not really an attractive option.
  4. Disable custom scopes or contextual scopes.  Using one of these approaches is the fastest way to eliminate confusion, but also results in limited functionality.
  5. Educate users on difference of functionality.  Part of this could be a blurb appearing on the simple contextual search results page indicating that more options are available when searching across wider scopes.

<script language = "javascript">
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
        aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
  return unescape(strReturn);
var urlstring = 'http://sharepointURL/_catalogs/masterpage/custom-search.aspx?k=' + getURLParam('k') + '&cs=' + getURLParam('cs') + '&u=' + getURLParam('u')


Comments (5)
  1. dumil says:

    Hi ,

    I am working on sharepoint 2007 server.

    The normal search is working but i m not getting the "people" and "allsites" in the dropdown though it is in search scopes.

    I created a site and used people search webpart(which is inbuilt) , but i am getting the following error when i use that search  :

    " HTTP 404 – File not found "

    what could be reason and how do i correct it?

    awaiting for your response…

  2. alimel says:

    Could you please give more details on your work around option 2?  We ran into this situation and are looking for a solution urgently.

    Thanks so much.

  3. Mark has a great post on Search scopes and the special contextual scopes. Good stuff Mark! If you want

  4. Mark has a great post on Search scopes and the special contextual scopes. Good stuff Mark! If you want

Comments are closed.

Skip to main content