#Assuming the correct RewriteBase is used...
#Redirect the client to the fancy url
RewriteCond %{QUERY_STRING} ^url=(.*)$
RewriteRule ^product_detail\.php$ %1? [R,L]
#Rewrite the url internally and stop rewriting
#to prevent a loop
RewriteRule ^(.*)$ product_detail.php?url=$1 [END]
このコードでは、最初にクライアントをアドレス バーに表示する URL にリダイレクトします。%1
RewriteCond の最初のキャプチャ グループに一致します。末尾?
はクエリ文字列をクリアします。2 番目のルールは、サーバーが 404 エラーの代わりに実際に出力を生成できるように、URL を内部的に書き換えます。END フラグ (apache 2.3.9 以降で利用可能; docs ) は、URL の書き換えを完全に停止します)。これは、URL が絶えず書き換えられる終わりのないループを防ぐためです。(ドキュメント)
編集: 2.3.9 より前のバージョンの apache には END フラグがありません。ループを防ぐには、それを回避する必要があります。たとえば、次のように使用できます。
#Assuming the correct RewriteBase is used...
#Redirect the client to the fancy url
RewriteCond %{QUERY_STRING} !redirect=true
RewriteCond %{QUERY_STRING} ^url=(.*)$
RewriteRule ^product_detail\.php$ %1? [R,L]
#Rewrite the url internally and stop rewriting
#to prevent a loop
RewriteRule ^(.*)$ product_detail.php?url=$1&redirect=true [L]