[resolved] When search I get forbidden 403 error mesg. (7 posts)

  1. sorknes
    Posted 3 years ago #

    I've added <?php get_search_form(''); ?> to my blog, and when I search my search result-page gives me:

    Forbidden 403
    You don't have permission to access / on this server.

    My .htaccess file is as follow:
    RewriteRule ^login$ http://work.leonorge.no/leonorge/new_site/wp-login.php [NC,L]

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /leonorge/new_site/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /leonorge/new_site/index.php [L]

    # END WordPress

    My permalink is set to display month and day.

    All my other sub-pages work as they should. Only my search result page is giving me a headache.

    Please help :-)

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Try just using <?php get_search_form(); ?>.

  3. sorknes
    Posted 3 years ago #

    Thanks for your suggestion esmi, but same error occurs. Any other suggestions?

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    From a functionality pov, http://work.leonorge.no/leonorge/new_site/?s=and&submit=Search seems to work OK (although the search template file needs attention).

  5. sorknes
    Posted 3 years ago #

    This is so strange. Haven't had this problem before. Tried to google it, but couldn't find any thread about this particular problem.

    The search template isn't done yet ;-P


  6. sorknes
    Posted 3 years ago #

    Found the problem!

    There was an error in my searchform.php:

    <form action="/" method="get">
            <input type="text" name="s" id="search" value="<?php the_search_query(); ?>" />
            <input type="image" alt="Search" src="<?php bloginfo( 'template_url' ); ?>/images/search.png" style="background-color: black;" />

    Used this function instead:

    function my_search_form( $form ) {
    	$form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
        <div class="searchform">
        	<label class="screen-reader-text" for="s">' . __('') . '</label>
        	<input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="Start typing here..." />
        	<input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" title="Search my site" />
        	<div class="clear"></div>
        return $form;
    add_filter( 'get_search_form', 'my_search_form' );

    Problem solved!

  7. esmi
    Forum Moderator
    Posted 3 years ago #

    Does your theme include a searchform.php template file?

Topic Closed

This topic has been closed to new replies.

About this Topic