我想要更改如下所示的url:
http://www.gsmsite.nl/zakelijk/product/phone?b=met-internet-250plus
至:
http://www.gsmsite.nl/zakelijk/product/phone?bundel=met-internet-250plus
我将如何使用.htaccess重写规则来做到这一点?
您需要针对QUERY_STRINGvariables使用RewriteCond 。
RewriteCond %{QUERY_STRING} ^b=(.*)$ [NC] RewriteRule ^/zakelijk/product/phone$ /zakelijk/product/phone?bundel=%1 [NC,L,R=301]
在PHP中执行任何业务逻辑redirect可能更为明智; 而不是使HTTPD行为复杂化。
if (isset($_GET['b'])) { location($_SERVER['PHP_SELF'].'?bundel='.$_GET['b']); exit; }