Don’t touch the .htaccess file, there’s this neat tool add_rewrite_rule()
which you should hook into init
:
add_action('init', function() {
add_rewrite_rule(
'search+([^/]+).html$',
'index.php?my_custom_search=1&s=$matches[1]&submit=Search',
'top'
);
});
Right after that you should flush the rewrite rules once ( by saving the permalink settings in Settings > Permalinks or with flush_rewrite_rules()
BUT call that function only once and when needed ).
This should make www.site.com/search+keyword.html
serve search results as www.site.com/?s=search+keyword&submit=Search
Related Posts:
- Apache Fallback instead of add_rewrite_rule
- how to combine wordpress htaccess on my root domain + php on subfolder
- custom url rewrite for wordpress
- NGINX rewrite rules for WordPress Subdirectory Multisite to support deep URL
- Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error
- Redirect vs RedirectMatch
- Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04
- How to remove index.php from WordPress site URL
- Redirect old php link to wordpress link in .htaccess
- Redirect old php link to wordpress link in .htaccess
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- How to create custom 401, 403 and 500 error pages?
- cURL 28 error after switch from to brew php 7.2 on localhost
- PHP – redirect https to http and www to non-www
- How to run multiple Async HTTP requests in WordPress?
- WP CLI info showing correct PHP binary but wrong version of PHP
- Does the debug.log do log rotation?
- Rewrite /?rest_route=/ link to /wp-json/ without changing default permalink structure in apache
- Bypass .htaccess when using download_url
- How can I run a .php file located in my site’s root folder?
- Fix 403 error on WordPress multisite network using subdomains
- Can I write ‘RewriteCond’ using ‘functions.php’?
- Create custom permalinks to show Custom Post Type’s relationship?
- WP & Server Speed [Teacher Question]
- Redirect to another page using contact form 7? [closed]
- WordPress add_rewrite_rules for custom URLs ending in .html
- Call to undefined function mysql_connect() After upgrading PHP 7.1 to 7.3
- How does WP work in conjunction with a web server?
- Troll the hackers by redirecting them
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- How to override url params with rewrite rules vars?
- Seo Friendly Filter URLs
- Permalinks are not working in WordPress in digitalocean
- How to allow download url redirection only if user logged in WordPress site?
- How to disable all logins except Network login in WordPress Multi site?
- Using rules in Posts
- Removing files programmatically
- Apache HTTP Server stops working for only a certain local website
- Is it possible to restrict files from your wordpress uploads (not logged-in users or guest)?
- Simple seo-friendly custom $_GET url rewrite with htaccess
- WordPress Rewrite Rule
- Problem with data collection in tables
- Prevent Buddypress Rewrite Rules on Non-Buddypress pages/posts
- Change permalink structure specific category
- How to make Subdomain work for product_tag?
- How to serve WordPress folder over subdomain?
- Pages from admin dasboard missing after site migration
- Rewrite rule not working, but only when parameter is text
- Internal Server Errors – Moving working multi-site install to my localhost
- Rewrite rule for wp
- How to edit content in WordPress and the Polylang – plugin? – with demosite
- Upgrade to PHP7.3 and Changing Apache from Prefork to Event Breaks WordPress
- Windows Setup: Error establishing a database connection
- Huge time to first byte on live site
- Deny php execution in /wp-includes – using .htaccess in /wp-includes VS root folder
- WAMP SERVER Command Prompt SET PATH=%PATH%
- How come there is no error if I upgrade WordPress core after locking .htaccess permissions to 644?
- How to block access to a folder inside of wp-content for non logged in users?
- WordPress Redirect / Add_Rewrite_Rule – Non Index.php Page
- How to change query string with pretty URL in WordPress using .htaccess file
- Upload images from one server to an other in wordpress
- 403 Forbidden Localhost Wamp Apache Php
- Problem with ajax request and directory structure after site migration
- Strange special character/Latin characters
- How can I add “.html” to the end of a single URL on a WordPress website?
- Resource 404 error on multisite subdirectory install
- redirect 301 with special character like WIX site “#!”
- 301 redirect from webpage to wordpress page in the same root
- add_rewrite_rule questions
- rewrite_rule – working fine but broken for pagination
- What to do after a wrong RewriteRule?
- Redirect homepage /page/1/ to /blog/page/1/
- Not logged in when using http
- Admin-area broken through weird issues
- Blog only showing code
- Enabling XSendFile causes 404 for images on WordPress Multisite / Network
- how to exclude admin page from add_rewrite_rule in wordpress
- Why I can download any file except PHP files from a URL but I can download any from another site?
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- Can’t get pretty permalinks to work without index.php
- WordPress Memory limit not increasing
- Having an HTTP error 500 after migrating a website
- session_start(): Cannot find save handler ‘mm’ – session startup failed in /sites
- how to put shortcode to the top of the page – theme 2014
- How to avoid timeout waiting for output from CGI script?
- How can I prevent wordpress from sending emails
- How to use multiple 404 Error Pages in WordPress
- WordPress add parameters with friendly url structure
- Increase Upload Size with htaccess | MAMP
- WP-Include rewrite directory
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- Restricting access to a file for everyone except logged in users
- wp-login – unable to redirect user to a custom login url
- Same Custom Post Type Slug and Custom Taxonomy Slug, with hierarchial unique permalink structure
- Change WordPress Multisite Domain to subfolder
- How to do SEO friendly filters urls?
- 404 Error after URL update
- How to Dynamically Change the author_base URL Slug by Language in WordPress?
- How to add global CSS to all webpages without installing any plugin?