Is your Search Bar not working in WordPress?

Yesterday i had an issue with the search bar and was wondering why..It just kept redirecting to the homepage…I managed to get it fixed but was wondering if anyone else had gotten this problem…What was causing it was the redirection of to¬† from within .htaccess i had set up…

It is a good idea to do this if you are running WordPress to stop creating a duplicate homepage as the search engines don’t like duplicate content…

Here is the solution if your .htaccess has a code similar to this in it –

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.buyers-web\.com$ [NC]
RewriteRule ^(.*)$$1 [R,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

If you are not using a redirection then search engines could index both or seen as two more duplicate pages…

Step two, edit the header.php…This is located in wp-content/themes/your theme?…around line 80…

From this –

<div class=”Search”>
<form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”post”>
<input type=”text” name=”s” class=”keyword” />
<div class=”bt”>

To this –

<div class=”Search”>
<form action=”” method=”post”>
<input type=”text” name=”s” class=”keyword” />
<div class=”bt”>

Make sure to include the slash at the end, other wise it will create a 404 page…I spent a good couple of hours working this out yesterday so i thought i would share it in case someone else had the same issue…

Speak Your Mind