How can I change this URL
http://mysite.com/index.php?searchterm=my+great+song
to
http://mysite.com/search/my-great-song.html
I am a beginner in mod_rewrite. That is why I can not figure out what to do. I would appreciate your help if you can tell me the .htaccess code that I should write in the .htaccess file to change the url.
You can try this code :
I tried its work
The following htaccess should work for you
I use environment variables
[E=a:b]
(docs) to control when spaces should be stripped and to prevent extensive amounts of redirects. TheN
flag makes the rewriteengine start from the top of the .htaccess file again. Therefore I put the stripspaces rule in the top, to minimize the amount of rules that need to be matched. The%1
in the second rules is a backreference to the first capture group in the rewritecondition. The trailing?
clears the query string. The documentation for all this can be found on httpd.apache.org.