It’s easy. Just add this hook for template_redirect
action and it will redirect your search queries to nice url:
function wpse8170_search_url_redirect() {
if ( is_search() && !empty( $_GET['s'] ) ) {
wp_redirect( home_url( "/something/" . urlencode( get_query_var( 's' ) ) ) );
exit;
}
}
add_action( 'template_redirect', 'wpse8170_search_url_redirect' );
Add to your .htaccess
file:
# search redirect
# this will take anything in the query string, minus any extraneous values, and turn them into a clean working url
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
RewriteRule ^$ /search/%1/? [NC,R,L]
Related Posts:
- How to remove “http://” When Echoing URL?
- WordPress Move to SSL How to Update Media Assets to HTTPS?
- How to Change 404 page title
- Problem with guids and absolute links
- Search multiple custom fields by using meta_query
- Search/Replace for editor in HTML-mode
- WPML Get url without outputting
- Filter results with custom field values and dropdown
- Weird: /?name in URL leads to blog
- Is there a way to do multiple ordering on a multiple meta_query?
- I am Looking to append URL Parameter to all URLs
- How do I amend the fixed “author” part in the URL?
- Search results with custom loop don’t update when paged
- Multiple keyword search
- Is dynamic URL possible in WordPress
- Accessing the Current URL in a Text Widget for a Facebook Share Button?
- Is ‘name’ a reserved word in URL’s?
- get_site_url is not returning anything?
- Custom search page and search by title, content and tag
- add_rewrite_rule not working for language specific characters
- How to create a custom page base on URL for WordPress?
- How to make menu items active based on hash
- Multiple domain names for one site
- How to change URL Custom Page?
- How to always rewrite author archive page URL even if the author does not have a post
- Add filename to attachment page url
- wp_query ‘s’ parameter does not work with custom post type
- Creating Search Engine Friendly URL’s with Word Press
- Pages other than Home page not displayed even when URL is good
- Moving a test WP site to live
- How do I write the link from front-page.php to home.php?
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- how to make URL link query string
- How do I test my localhost WordPress project with VirtualBoxVM?
- How do I link to a blog not set as the homepage?
- Save URL into database
- Use “search” in permalink?
- Steps for custom data retrieval
- Change url links on members loops in buddypress
- Imported 10 000+ posts, custom field showing link not displayed
- How do i search authors from search form using author’s name
- How to add URL-Parameter for Javascript Widgets?
- previous_posts_link and next_posts_link, how to return the next/previous post’s title as the url
- Get Top parent url
- hide wp-content from urls
- Changing the website URL to the root folder
- Open editor post in a popup
- Organizing the Navigation Menu
- Showing my server ip in source code for several links not for all links
- What php gets called for home_url/somepage URL?
- Moving Website-URL
- How to prevent unknown addresses which are accessed from my wordpress website [closed]
- Use wp_redirect to add a parameter
- two search forms on the same page
- Site Title in my Search URL
- Extracting a variable from a permalink
- Is there an URL listing latest posts
- After changing the site root, how to reflect this for wp-admin too?
- How can I prepopulate the URL address for the add media button
- How do I get posts to appear at mydomain.com/blog?
- title tag function
- How to show Specific URL of WordPress on Any one Specific IP only?
- How to make a seo friendly URL of 2 different pages with same words
- How to add url parameter to every search query in SearchWp?
- How to change search page url so that it still returns a page when there’s no search query specified?
- Mapping a domain name
- No https in url when writing links like:
- Why “?v=hash” is added to my URLs? [closed]
- WordPress inserting ?q= in URLs
- I want to change url structure of my created archieve pages
- No url when downloading PDF
- Set A Cookie To URL Parameter, Pass Cookie From Page To Page To Alter Post
- Embed ACF URL Field in WP title field
- Getting Turkish alphabet characters in the URL field in webbrowser
- Replace an URL with an new URL which has a “?” in it
- In-page link works in Firefox but not in Chrome
- How to properly setup MAMP and XIP
- URLs fine in database but wrong in output
- Cannot access to dashboard on localhost
- My website has some Crawling Errors?
- Change output URL Search module
- Custom URL Structure for posts with subcategories
- Call a duplicate registration form with other url
- How to set global variable in functions.php
- Why am I seeing ‘yes’ and ‘no’ in URLs crawled by Xenu?
- Cannot get query var ‘post_type’ to work
- URL with without www shows just a blank page
- How to create custom authors links
- How can i retrive the movies, trailers, news in a single page using search
- Using functions concatenated with strings inside a variable
- Pass query param to custom page
- How to generate external url in WordPress
- All font sizes change when manually typing 2011 into url and going to archive page
- apply styling only to a specific url
- How do I fix the url when clicking on portfolio item?
- How can I implement an Article Wizard for non-existing URLs? [closed]
- Replace media external links with local links
- Show total sales for each products on search results page Woocommerce
- Custom Search on media files PDF images pages posts
- how to add param string after website url in wordpress?