Write this in your theme’s functions.php.
Hope this helps you out.
function code_search() {
if ( is_search() &&
strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false &&
strpos($_SERVER['REQUEST_URI'], '/search/') === false ) {
wp_redirect( get_bloginfo('home') . '/search/' . str_replace(' ', '_', str_replace('%20', '_', get_query_var('s'))));
exit();
}
}
add_action('template_redirect', 'code_search');
Related Posts:
- Need logged in users returing to site redirected to a separate page
- Creating search form for custom database table
- Search through custom post type and custom fields takes 5 minutes
- How to let a single post have its own domain name
- Redirect members to custom page upon logging in through WP admin
- Redirect to requested page after (custom) login
- Customise search form in the Widget
- Comment filtering (search)
- Combine multiple words in custom meta search query
- Custom search page and search by title, content and tag
- Hide Login information in Account settings in Buddy Boss
- Search a post using the date it was posted
- Setting custom search engine indexing for a “dynamic WordPress page” with htaccess
- Turn off redirect to canonical domain (or host website on any hostname)
- Custom URL going to 404
- Hi, I wanted to make custom search with multiple fields
- Steps for custom data retrieval
- Custom search to display results within same page
- Search widget will search everything in the site, how to limit to only search gallery name
- How to hook up search results page to a back-end page?
- Admin search post meta
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- Add a searchbox to the body of a page
- Custom Search on Custom Page while preserving the main search function
- Custom Loop Query For Search Page
- Search URL parameters query [duplicate]
- Applying WP-cli Search & Replace to Static SQL Dump File
- How to create custom search page
- How do I create a root link in wordpress to a PDF file?
- Restrict content access to logged in users
- Showing different pages depending on a cookie value
- Custom Same Page Search
- How to Add Additional Search Button?
- How to Clear Empty Search values?
- WP Search Form Query: Add Author’s posts into search query
- WordPress search on a custom table
- Adding overlay search to wordpress using add action/filter
- Block direct access to thank you pages
- Allow WP users to sort search result on a videos site
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- Custom Route Returns 301/Passing Variable from Input
- Custom dropdown search form that allows users to select option B based from Option 1
- Custom search results
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Allow arbitrary text after page URL
- WordPress custom search – pagination
- Creating a search with tag variable also added for more detailed results
- What shortcode should I use for
- Two searchforms with different categories/posts per page
- Search a meta field for a value in all posts
- Custom search by several options send on form not works
- Search results load individual post in slide out div
- Custom Search Results Page
- WordPress Search on Multiple wp sites
- Create a custom search for Estate Agency WordPress site
- How can I make a search term redirect to a page
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- Show total sales for each products on search results page Woocommerce
- Redirect all pages to the custom login page except for the registration page
- Custom Search on media files PDF images pages posts
- Redirection after Category Change for Custom Structure
- Customizing gallery shortcode in 3.5
- Can You Export Theme Settings From WordPress Multisite?
- Any Hook Called When Post Becomes Published?
- Automatically wrap post image in div
- How Can A Widget With Only One Instance Be Defined?
- WordPress Template not affecting the working, keeps defaulting to the index.php template
- Custom Widget form function common elements
- WP Northwind for Theme Development?
- list/consult Taxonomy only for the respective author/creator in dashbboard
- How to insert a sitemap within a subsite when using WordPress multisite
- Enabling Additional CSS / custom-css
- Child Theme – how to add new widget on a specific place?
- Follow me for WordPress blogs (multi-authors)
- Pagination Issues using WP_Paginate Plugin
- adding multiple custom columns to users.php
- Get Image from Media Library with the Title
- Allow a Widget to be used one time only?
- Keyword search in multiple categories
- Best way to allow overwriting images shipped with the plugin?
- Static Front Page settings – distinguish between Front page and Post page
- How to format text of site subtitle
- How to print Array values of custom Fields Meta?
- Undefined variable: user_id in get_user_meta
- Customizer JS API get value of customizer field
- WordPress broken after domain name change
- Daylight Saving Time adjustment
- Hide content and functions from specific user roles
- Translating (WooCommerce) placeholder text
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Can we set a redirection with dynamic content in url?
- How to remove (…) from the post tilte on homepage?
- How can I setup a development environment which auto refresh page when code have changed [closed]
- Fixed bottom menu on mobile doesn’t work on search included in Child Theme of Storefront
- Change Dashboard menu position?
- Get site ID from attachment url?
- duplicate featured image functionality in custom meta box
- How to automatically pull an information from a form field onto an other page?
- How to create a custom menu for specific user
- Customize TinyMCE Buttons