You can use the template_redirect
action to add /search/ to your search URL’s. Check out the code below:
function my_change_search_url() {
if ( is_search() && ! empty( $_GET['s'] ) ) {
wp_redirect( home_url( '/search/' ) . urlencode( get_query_var( 's' ) ) );
exit();
}
}
add_action( 'template_redirect', 'my_change_search_url' );
Related Posts:
- Redirect empty search to another page
- Why is there a 404 on page 2+ for my search page?
- Unique URL Every Time
- Custom slug in front of search URL
- How do i change the search permanent links
- Why is there /index.php/ in all my links? How do I remove it?
- add_rewrite_rule not working for language specific characters
- Changing the search URL?
- Rewrite: WordPress URL rewrite on Search
- Force search form to go to clean url without multiple redirects
- How to create a front end user profile with a friendly permalink and a 404 trigger
- WordPress search rewriting
- Attachment page gives 404 if user not logged
- Using a custom 410 page
- Why when I enter bad url wordpress doesn’t return error 404
- 404 redirect based on url
- Change /search to /somethingelse
- Thousands of 404 errors on old posts due to embedded links
- Adding Theme File for Non-WordPress Content
- WordPress how to prevent URL encoding in URL of taxonomy terms
- Show index.php template instead of 404 page template
- Changing the wordpress default search url to something like – …example.com/search?query=keyword
- How to change search page url so that it still returns a page when there’s no search query specified?
- Custom taxonomy named ‘tag’ return 404 page
- How to add Search URL parameters to a Page Template Page for Custom Post Type
- Param causing 404
- Rewrite URL for Search + Special Characters / Umlaute
- Error 404 wordpress redirecting URL
- add_rewrite_rule is not fired
- Change the search URL
- How to turn off searching from URL and go straight to 404 page
- Stop wordpress to redirecting home page if no page found
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- 404 for index.php
- How to make custom WordPress page deliver search results
- How to disable WordPress canonical redirect to nearest matching URL and force 404 Page?
- Masking wp-content/themes/name/images to just images directory using htaccess
- How do I remove a rewrite rule?
- Use subdomain for certain urls
- Can I call a custom plugin with a direct URL
- Display posts with author in the url with custom post types
- Clash of the rewrites
- Query Vars for the Homepage?
- Disable wordpress pagination URL rewrite for specific page
- How to use Post Custom Metadata in Post Titles and Post Permalinks
- Appending numbers to url do not break the link
- Custom rewrite rules are sending everything to index.php
- WordPress Network on IIS7/SQL Server – Rewrite Issues
- Custom comments
- WordPress 404 unless there is a space in url
- Add .html extension to only one page in my WordPress site
- Migrating a page to be an article
- How to get “extended” path info from URL in a plugin
- Custom URL routing based on cookie value
- Rewriting rules: difference between ‘init’, ‘rewrite_rules_array’, ‘generate_rewrite_rules’?
- Multiple Permalinks for Same Post
- url rewriting for most recent post
- Remove “/page/1” from the URL
- hard flush_rewrite_rules() not regenerating .htaccess
- How to return HTTP 404 when no search results found?
- Nginx rewrite rules
- Use custom template on certain URLs
- How does WordPress know if a URL doesn’t exist?
- custom template rewrite
- How do I redirect to a non-www version and make it the default URL?
- WordPress redirects non-existing url to existing ones – how to disable
- How to create a profile page for specfic / custom user role members?
- Can I change default registration link (without htaccess)?
- A clean custom rewrite rule for weekly archives
- Custom post URL 404 error
- QSA Rewrite Rule
- rewrite wordpress page url for seo friendly query strings
- ReWrite rule for files of a previously standalone blog moved to network
- Fixing custom rewrite rule
- URL renaming issue
- Best way to trigger rewrite rules
- virtual page using url parameters to solve facebook sharing issues
- Clean Custom URL for Serach + Custom Taxonomy
- What URL rewriting rule should I write to retrieve a var in the URL?
- WordPress pages and posts are redirecting to server IP address instead of domain URL [closed]
- Hard to find a good rewriting rule
- Mobile version and URL Rewrite
- How do I make WordPress revise an .htaccess file a certain way?
- How are rewrite rules applied in WordPress?
- Use URI suffix as parameter and ignore when resolving page
- Rewrite the search page to use an appended slug + parameter
- Why wordpress rewrite my custom URL?
- Change author base and slug in author link
- Rewrite rule not working, suspect redirect string
- Rewrite Url using .htaccess or hook
- Custom taxonomy Rewrite Rule
- taxonomy term in URL slug won’t forward to the correct term for custom post like it does for default categories/normal posts
- WPNetwork with custom URL Rewrite rules
- WordPress index page is returning 404 and admin page requires /index.php in url
- Rewrite URL variable to custom path
- Own code on index.php wordpress theme file, help with the rewrite rules
- URL rewrites af
- Lost WordPress website access after changing URL [closed]
- Post pages are redirecting to the 404 page in wordpress
- Problems Implementing Non-WordPress Rewrite Rules