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] 
  1. showing rewriteengine , rewritebase
  2. remove $ in rewritecond
  3. 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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -