html - Using htaccess to rewrite URL with GET variable to page title -


i trying rewrite url like:

http://example.com/shop/item.php?id=2 

to like:

http://example.com/shop/my-page-title-2.html 

because of possibility of having multiple items same page title, want add id url, each id unique , ensure not have duplicate url's.

the page title should rewritten in lowercase url.

any appreciated!

you can following rule :

rewriteengine on rewritecond %{the_request} /shop/item.php\?id=([^&\s]+) [nc]  rewriterule ^ /my-page-title-%1\.html? [nc,r,l,ne] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^my-page-title-([^.]+)\.html$ /shop/item.php?id=$1 [qsa,l,nc] 

Comments