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.

Search results not displaying with .htaccess file

October 13, 2011 6:44pm

Subscribe [2]
  • #1 / Oct 13, 2011 6:44pm

    pete_u

    18 posts

    I’ve got a standard .htaccess file set up on my site to remove index.php:

    <IfModule mod_rewrite.c>
            RewriteEngine On
    
            # Removes index.php
            RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /index.php?/$1 [L]
    
            # If 404s, "No Input File" or every URL returns the same thing
            # make it /index.php?/$1 above (add the question mark)
    </IfModule>

    As soon as this was set up, the EE Simple Search Form I had running fine on my site stopped working - clicking the search submit button now redirects to the site homepage instead of the search results page.

    If I remove .htaccess and reset the name of the site homepage to index.php, the search works again.

    Is there any way to get simple search working on a site without index.php?

    Here’s my search code:

    {exp:search:simple_form result_page="search/results" no_result_page="search/no-results" results="10"}
    <label for="keywords">Search:</label>
    
    <input type="text" name="keywords" id="keywords" value="" size="18" maxlength="100">
    <input type="submit" value="submit" class="submit">
    {/exp:search:simple_form}

    Any help gratefully received!

  • #2 / Oct 15, 2011 12:34am

    ralph.m

    225 posts

    Simple search works fine for me if I use this .htaccess rule:

    <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule (.*) index.php/$1 [L]
    </IfModule>

    There’s only one time I’ve seen the behavior you are describing, and that was when I had a temporary index.html page fronting the website (during development). That gets in the way, so you have to delete it temporarily to make sure the search fucntionality is working.

  • #3 / Oct 15, 2011 10:14am

    pete_u

    18 posts

    You star Ralph!

    I have got a temporary index.html (holding) page on the site. I deleted it and the search works.

    I just didn’t think to try that, so thanks!

    Pete

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases