Modify WordPress search result URL using .htaccess file Code Answer

I’m currently experimenting with a WordPress website that uses a modified search.php file to show dynamic web pages.

When a search term is entered it produces a URL similar to:

Is it possible to add a rule(s) to my .htaccess file that changes the result URL into something more friendly without effecting the search.php function? Eg:

or, even better: NAME/search-term.html


I don’t think you can achieve this without .html or any other trick, because by default WP uses clean URLs for posts, so you can’t mess the functionality, but you can do something like this:

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

Related Posts

© No Copyrights, All Questions are retrived from public domain.
Tutorial Guruji