I am facing trouble redirecting the keywords to search page in a wordpress 4.4 setup. What I am trying achieve is to rewrite/redirect




I have tried every solution found in google but none works with this version.

.htaccess file:

    <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
RewriteRule ([^/]+)\.html$ ./?s=$1 [L]


I can search wordpress using: http://localhost/wordpress/search/keyword, but I am unable to change the search URL.

What I need is to fire a search whenever there is a keyword followed by a .html in the URL. How can I get this done?

1 Answer 1


Don't touch the .htaccess file, there's this neat tool add_rewrite_rule() which you should hook into init:

add_action('init', function() {



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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.