none
Replacing “OSSSearchResults.aspx” with “/SearchCenter/Pages/Results.aspx”.

    Question

  • Hi guys, every time a user make a search using “this site” option the results page is “OSSSearchResults.aspx” but I need to replace this with “/SearchCenter/Pages/Results.aspx”.

    To do that, I went to the top level site in my site collections, then to Site Actions > Site Settings > Search Setting   and change the default search location to /SearchCenter/Pages/Results.aspx” and nothing happened.

    Besides how can I delete “this site” from the drop down menu? It is not listed under my scopes.

    Thanks!!

     

     

    • Changed type Mike Walsh FIN Monday, April 27, 2009 3:03 PM always use the Question type so people get credit for their replies
    • Edited by Mike Walsh FIN Monday, April 27, 2009 3:04 PM t"I need some help here, please. " removed. Yet another variant on the "urgent"; "asap" theme. Just wait and you'll get a reply. No need to push us.
    Monday, April 27, 2009 2:59 PM

Answers

  • If you are doing a search using the top level search box of your root site, this is a known limitation where you are always redirected to osssearchresults.aspx instead of the configured search center.
    In order to redirect the search to the preferred search center, edit the Osssearchresults.aspx page. The Osssearchresults.aspx file is located on the web front-end server, in the following folder by default  \Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS. Insert the code provided below before the “</script>” tag.

    
    
    
    
    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];
    
    
    
              break;
    
    
    
            }
    
    
    
          }
    
    
    
      }
    
    
    
      return strReturn;
    
    
    
    }
    
    
    
    
    
    
    
    var urlstring = '/SearchCenter/Pages/results.aspx?k=' + getURLParam('k') + '&cs=' + getURLParam('cs') + '&u=' + getURLParam('u');
    
    
    
    
    
    
    
    location.replace(urlstring);
    thanks!

    sNjY
    Friday, May 01, 2009 2:25 PM

All replies

  • If you are doing a search using the top level search box of your root site, this is a known limitation where you are always redirected to osssearchresults.aspx instead of the configured search center.
    In order to redirect the search to the preferred search center, edit the Osssearchresults.aspx page. The Osssearchresults.aspx file is located on the web front-end server, in the following folder by default  \Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS. Insert the code provided below before the “</script>” tag.

    
    
    
    
    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];
    
    
    
              break;
    
    
    
            }
    
    
    
          }
    
    
    
      }
    
    
    
      return strReturn;
    
    
    
    }
    
    
    
    
    
    
    
    var urlstring = '/SearchCenter/Pages/results.aspx?k=' + getURLParam('k') + '&cs=' + getURLParam('cs') + '&u=' + getURLParam('u');
    
    
    
    
    
    
    
    location.replace(urlstring);
    thanks!

    sNjY
    Friday, May 01, 2009 2:25 PM
  • Thank you so much !!

    It worked !!
    Friday, May 01, 2009 4:19 PM
  • That is not supportable supposedly but worse not an option when you only want to redirect one web application (portal) and not all sites within a farm.  Any other clear steps to change this behavior?

    Thanks
    Monday, August 17, 2009 9:03 PM
  • The search scope dropdown that you see on SharePoint sites is implemented in a delegate control.  If you look in the master page for a site collection, all you'll see for the search scope dropdown and search box is the following markup:

        <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
            <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox"/>
        </asp:ContentPlaceHolder>

    The functionality that adds the contextual search scopes (This site/This list) is coded in the SmallSearchInputBox delegate control.  This control is stored in ...\12\TEMPLATE\CONTROLTEMPLATES\SearchArea.ascx. 

    A method does exist to override the delegate control WITHOUT modifying each master page that reference it; i.e. no master page change required.

    This link should get your started:
    http://msdn.microsoft.com/en-us/library/bb861966.aspx

    Hope this helps.

    Tuesday, September 01, 2009 1:45 PM
  • Ryan, I don't really get your explaination. Your idea is about modifying the search scope dropdown??? Is there anything to do with issue raised by Allison?

    sNjY, there many sites collections within the farm that I am hosting and I have to make sure my fix won't impact other people's sites. Does your workaround can just work for one specific site collection?

    Now I am also considering about hiding the search scope contextual from the dropdown list search box, cause I am not so condifent about the redirecting.


    Vuthy
    Wednesday, October 14, 2009 10:35 AM
  • Help.  I'm obviously, doing something wrong.  I've included the code in Osssearchresults.aspx.  The search results will be directed to my search center but only after I've done a successful search using the search center.  After that initial search, again, at the search center site, any searches using the search box on the top level site work correctly.  A search done using that same search box before a search done using the search center fails with an error.  Any ideas?

    Thanks ahead of time.


    Paul
    Friday, November 13, 2009 6:42 PM
  • It worked, thanks for this code. I was looking for it for a while. RJ
    Tuesday, November 17, 2009 6:41 PM
  • Hi pczemy, you'll notice that the default Search Centre pages are basic ASPX pages int he site root. This means they don't benefit from any Custom Master you may have applied. Ta da!

    Providing a custom delegate control is by far and away the best solution to what is clearly an oversight and just another case of BDC (By Design ____). :)
    If at first you don't succeed, ask an MVP. Or find someone who really knows. ;)
    Monday, February 22, 2010 10:18 PM
  • Bear in mind that any changes you make to Osssearchresults.aspx will likey be overwritten when applying a Service Pack or hotfix to SharePoint.

    (Been there, got the teeshirt)
    Thursday, February 25, 2010 7:24 AM