WarpConduit Computing

  • Quick Tips
  • Web Design & Development
  • WordPress Plugins
  • Home
  • Passphrase Generator
  • Password Generator
  • About
  • Contact

Fix Redirection and Error Page On Empty WordPress Search

August 2, 2011 by Josh Hartman

I found out just recently that in some cases when you perform a blank search on a WordPress site you are redirected to the front page with an error message. If you encounter this issue simply apply the fix below, which modifies the blank search into a search for one space. This is enough to resolve the error page and land you on the search page.

Add the following code to your theme’s functions.php file to fix this annoying behavior:


if(!is_admin()){
	add_action('init', 'search_query_fix');
	function search_query_fix(){
		if(isset($_GET['s']) && $_GET['s']==''){
			$_GET['s']=' ';
		}
	}
}

Filed Under: Web Design & Development Tagged With: error, redirect, search, wordpress

Redirecting to www with htaccess

September 25, 2009 by Josh Hartman

This is useful for SEO so all your ranking gets added to one url and not divided between two.

Use the following example to create a redirect from any incoming domain to your www sub-domain:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</IfModule>

To use this method you need have mod_rewrite installed and enabled on Apache web server and you need to be able to create a custom .htaccess file.

A few things to note, the NC means that the regex is not case sensitive, R=301 means that this redirect will return an HTTP status code of 301 Permanent Redirect (search engine friendly), and the L after that means that no further rule processing should be done.

Filed Under: Web Design & Development Tagged With: htaccess, redirect

Connect

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • Extremely Useful Applications for Web Development and IT Tasks
  • Installing BookStack Wiki on cPanel Shared Hosting
  • Media (MIME) Type Reference List

Tags

automatic benchmark cbc cipher class comparisons cpanel credit memo css decrypt encrypt font gzip htaccess html image increment javascript jquery list magento mcrypt mysql number old opencart order php profiling random redirect repository rijndael shipment software strict ubuntu url wincachegrind windows windows 7 wordpress xampp xdebug xss

Blogroll

  • CodeIgniter
  • Fusion Forward
  • jQuery
  • Nettuts+
  • Smashing Magazine

© 2023 WarpConduit Computing. All Rights Reserved.