I think it is better that you do this inside the WordPress install, not on the .htaccess. Is not easy to maintain and maybe a problem, if you have more results for a search. You can use the follow source, write in a small plugin and activate. If the search result have only one result, then will rewrite to the single post.
add_action( 'template_redirect', 'fb_single_result' );
function fb_single_result() {
if (is_search()) {
global $wp_query;
if ( 1 === $wp_query->post_count ) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
exit();
}
}
}
Related Posts:
- Turning Broken URLs Into Search Terms?
- Search results URL without query string variables
- How do I properly redirect outbound links with special characters
- How can I get a traceback on function calls?
- How can I implement a location based (zip code) search in WordPress?
- How to highlight search terms without plugin
- Template issues getting ajax search results
- Complex Search functionality. Advice needed
- How to use next_post_link and previous_post_link on single posts in search results
- Why is there a class=”screen-reader-text” on my search button?
- can’t limit search to only pages
- Include custom table into search results
- Return all Tags from search results
- Search results with custom loop don’t update when paged
- ElasticPress Indexing multiple sites
- How to search through pdf media files?
- WordPress Single Conditional for Search Page
- Do not allow to search certain words
- get_query_var(‘s’) not working
- Display title for search engine visitors
- How to avoid the specific page while searching in WordPress without plugin?
- How to show a random selection of posts from the search
- Related Tags Concept
- Default WP search excluding specific characters, is it possible?
- Comparing between a negative and positive number
- Searching by meta values showing inappropriate result
- Search by keywords with boolean operators
- Redirect All Search Links Containing – to + on WordPress
- How to make wordpress Dynamic Search-Bar from Predesigned Static Html Search-Bar?
- Change Search url slug for each site in a multisite network
- URL search link for ‘category__and’ instead of php query
- Search media by title and description – Frontend
- Is there a way to add a custom text + link above search results for different searches?
- How to change tab’s title in search results pages? [closed]
- Customise Excerpt start and end
- Generate list of tags from search results
- Use created page as search results page and custom template
- Template issues getting ajax search results
- How can I implement Search feature for Membership site?
- WordPress search with quotations returning to homepage
- How to display search results in search.php
- Search WooCommerce Products in WordPress
- Search for two strings in WP search
- Sort search results by Custom Field
- Strip HTML Tags From Search Results
- Should I create a parent page with no content? [closed]
- some one help . search not jump to search page
- Why should we use the name attribute with the value “s” in the creation of the search form?
- The Search FoRM Dilemma || The Search form Templating
- Search for anything in site
- How can I add search box in single.php?
- Independent search tool that returns exact match of a post title
- Connecting Google Site Search with WordPress Taxonomies/Categories/Tags
- Only display post content in search results
- My search form finds page 1 results but shows “error 404 page not found” on pages 2 on or clicking next
- meta post search
- search page not found? (search.php or searchpage.php)
- Media Library / Backend: How can I search for text in the ALT Text field?
- Rewrite wp function
- Search custom posts by meta key in admin
- How to fetch Email addres of an author via ID?
- How to Fix Form elements do not have associated labels in WordPress Search Form (without button)
- Search within the current page
- How to exclude specific post_type from default search?
- What are the available options for “Name” in WP search?
- how to make search with two input boxes
- Search issue on special Character
- Modify main search form to search user too
- Editing a Search Form
- Removing &submit=Search from search parameters?
- customize search result in wordpress
- Highlight search words in excerpt
- $_GET value is losing it’s space
- limit the number of searches
- Search For Custom Post Type and Custom Fields
- How can I prevent the Search Results Page from changing title?
- Problem with site’s search results “Read More” link?
- Searching on my blog is not working
- WP search in metadata post
- “Modular/reusable” content and search results
- Make the title and […] clickable in result search
- Add Search Form to Dropdown menu
- Search doesn’t work with ‘relation’ => ‘OR’
- Add meta tag to search results
- Searchform for searching specific categories
- Selectbox and Searchform and Custom Search Page
- Hightlight search-terms with functions does remove or disable other filters?
- wp_redirect and search engine bots
- SQL: Search query to get attachments only of those parents which are published
- Change the text “search result for” on search result page
- Search redirects to index
- Want to creat a search for my wordpress theme [closed]
- How to remove search bar from the blog post
- Return 404 for /search/ queries – For Genesis
- Deprecating WordPress URL from Google, promoting custom domain [closed]
- Search with multiple selects that include tags
- Search results from a specific database table
- WordPress Search – Reject partial matches
- Wp query search built out of 4 terms?
- Ivory Search error