apache - mod rewrite of query strings -
say wanted http://domain.com/product/?id=123
become http://domain.com/product/foo
, how do in .htaccess
? tried this, didn't work:
rewritecond %{query_string} ^id=123$ [nc] rewriterule ^/product$ /product/foo [nc,l,r=301]
suggestions?
note: not need capture value of id
parameter not use in new url.
update 1:
rewriteengine on rewritebase /fisher rewritecond %{query_string} ^id=123 [nc] rewriterule ^product/$ /product/foo [nc,l,r=301]
- showing rewriteengine , rewritebase
- remove
$
in rewritecond - remove
/
in rewriterule
when go http://localhost/fisher/product/?id=123
, nothing happens. url remains same.
http://localhost/fisher/product/?id=123
taking above url request example, may try in .htacces file @ /fisher
directory:
options +followsymlinks -multiviews rewriteengine on rewritebase / rewritecond %{request_uri} ^/fisher/product/? [nc] rewritecond %{query_string} id=123 [nc] rewritecond %{request_uri} !/foo [nc] rewriterule .* /fisher/product/foo? [r=301,l,nc]
for internal , silent mapping, replace [r=301,l,nc] [l,nc]
Comments
Post a Comment