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 http://www.buyers-web.com/index.php to¬† http://www.buyers-web.com 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$ http://www.buyers-web.com/ [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.buyers-web\.com$ [NC]
RewriteRule ^(.*)$ http://www.buyers-web.com/$1 [R,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If you are not using a redirection then search engines could index both http://buyers-web.com or http://www.buyers-web.com/index.php 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=”http://www.enter-your-website.com/” 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

*