How to rewrite string in .htaccess

85 views Asked by At

www.domain.com/search/?searchword=honda&op=Search

rewrite to below

www.domain.com/search/honda

honda is input value. (input's name attribute is searchword)

Please help me.

1

There are 1 answers

0
Jon Lin On

Try adding this to the htaccess file in your document root

RewriteEngine On

RewriteCond %{THE_REQUEST} ^(?:GET|HEAD)\ /+search/?\?searchword=([^&]+)&op=Search
RewriteRule ^ /search/%1? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^search/(.+)$ /search/?searchword=$1&op=Search [L,QSA]