ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Not getting search results -- getting home page instead.

August 16, 2011 4:56pm

Subscribe [4]
  • #1 / Aug 16, 2011 4:56pm

    Versa Studio

    572 posts

    EE v2.2.1 - Build: date 20110705

    My .htaccess file works fine for everything, it is included here.

    When I search for a term, I just get the home page.

    Search code:

    <div id="searchBox">
        {exp:search:simple_form channel="not contact|widgets-basic|glossary" result_page="search/index" no_result_page="search/noresults" search_in="entries" status="open" form_id="searchy" name="searchy"}
            <fieldset>
                <label for="keywords" class="hide">Search this site:</label>
                <input type="text" class="textinput" name="keywords" id="keywords" value="" maxlength="100" />
                <input type="submit" value="Search" id="searchSubmit" class="button" />
            </fieldset>
        {/exp:search:simple_form}    
    </div>

    .htaccess

    # -- NSM .htaccess Generator Start --
    # .htaccess generated by NSM .htaccess Generator v1.1.4
    # @see: <a href="http://ee-garage.com/nsm-htaccess-generator">http://ee-garage.com/nsm-htaccess-generator</a>
    
    # For more awesome .htaccess rules and optimisations
    # checkout the HTML5 Boilerplate .htaccess files
    # <a href="https://github.com/paulirish/html5-boilerplate/blob/master/.htaccess">https://github.com/paulirish/html5-boilerplate/blob/master/.htaccess</a>
    
    # Although highly unlikely, your host may have +FollowSymLinks enabled at the root level,
    # yet disallow its addition in .htaccess; in which case, 
    # adding +FollowSymLinks will break your setup (probably a 500 error), 
    # so just remove it, and your rules should work fine.
    # Options +FollowSymlinks
    
    # EE 404 page for missing pages
    ErrorDocument 404 /index.php/home/index
    
    # Simple 404 for missing files
    <FilesMatch "(\.jpe?g|gif|png|bmp|css|js|flv)$">
      ErrorDocument 404 "File Not Found"
    </FilesMatch>
    
    # Rewriting will likely already be on, uncomment if it isnt
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    </IfModule>
    
    # Block access to "hidden" directories whose names begin with a period. This
    # includes directories used by version control systems such as Subversion or Git.
    <IfModule mod_rewrite.c>
      RewriteRule "(^|/)\." - [F]
    </IfModule>
    
    # remove the www - Uncomment to activate
    <IfModule mod_rewrite.c>
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    </IfModule>
    
    # Remove the trailing slash to paths without an extension
    # Uncomment to activate
    # <IfModule mod_rewrite.c>
    #   RewriteRule ^(.*)/$ /$1 [R=301,L]
    # </IfModule>
    
    # Remove index.php
    # Uses the "include method"
    # <a href="http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method">http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method</a>
    # <IfModule mod_rewrite.c>
    RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC]
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} ^/(home|includes|resources|widgets|about|education|technical-assistance|research|test|accessibility|sitemap|contact|entry-includes|page-includes|search|contributors|_DOCUMENTATION|calendar-testinc|calendar-testmain|members|P[0-9]{2,8}) [NC]
    RewriteRule (.*) /index.php/$1 [L]
    
    # -- NSM .htaccess Generator End --
  • #2 / Aug 16, 2011 5:25pm

    Rob Allen

    3114 posts

    I presume you have a template for the search results page - search/index ?

    Try adding in a template for the no results parameter - no_result_page=“search/noresults” - test the form again to see if you’re actually getting search results or not, that might offer some clues.

  • #3 / Aug 17, 2011 2:46am

    John Henry Donovan

    12339 posts

    Versa Studio,

    Can you visit http://www.yorudomain.com/search/index and http://www.yorudomain.com/search/noresults

    What happens in both cases?

  • #4 / Aug 22, 2011 7:07pm

    Versa Studio

    572 posts

    http://percthinkwork.org/search/index yields standard EE msg:

    Search Results:
    
    Your search did not return any results.
    Return to Previous Page

    http://percthinkwork.org/search/noresults

    yields the proper styled template with the correct ‘no results’ message.

  • #5 / Aug 22, 2011 7:26pm

    Lisa Wess

    20502 posts

    Can you try removing these two rules:

    # remove the www - Uncomment to activate
    <IfModule mod_rewrite.c>
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    </IfModule>
    
    # Remove the trailing slash to paths without an extension
    # Uncomment to activate
    # <IfModule mod_rewrite.c>
    #   RewriteRule ^(.*)/$ /$1 [R=301,L]
    # </IfModule>

    and see if the form submits? Usually this happens when the domain mismatches so the form submission fails.

    I’d also recommend using our supported method of removing index.php.

    does that help?

  • #6 / Aug 22, 2011 9:00pm

    Versa Studio

    572 posts

    I commented out these lines:

    <IfModule mod_rewrite.c>
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    </IfModule>

    and now it works. How does removing the www interfere with search? I’d like to keep the remove www. part of .htaccess.

    Thx.

  • #7 / Aug 22, 2011 10:27pm

    Lisa Wess

    20502 posts

    It’s generally a domain mismatch between the www. form and no www.  You’ll need to ensure that all access to the site never have the www.  the same thing can happen with the trailing slash removal as well.

    I’m going to shift this down to Community Help as well since it is not a strictly EE issue, others may have run into this and have advice as well.

    Thank you!

  • #8 / Jul 22, 2012 8:59am

    nigelheap

    1 posts

    I fixed this be just making the site_url = / .. this way it doesn’t matter if you are on www or not… it will just stay the same.

    $config['site_url'] = "/";
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases