0

I want to change URLs like below:

http://www.gsmsite.nl/zakelijk/product/phone?b=met-internet-250plus

To:

http://www.gsmsite.nl/zakelijk/product/phone?bundel=met-internet-250plus

How would I do that with an .htaccess rewrite rule?

  • Are you sure? Both of those return 404. – Michael Hampton Oct 5 '12 at 13:45
1

You would need to use a RewriteCond against the QUERY_STRING variable.

RewriteCond %{QUERY_STRING}  ^b=(.*)$  [NC]
RewriteRule ^/zakelijk/product/phone$  /zakelijk/product/phone?bundel=%1  [NC,L,R=301]

It might be wiser to do any business-logic redirects in PHP; rather than, complicating HTTPD behavior.

if (isset($_GET['b'])) {
  location($_SERVER['PHP_SELF'].'?bundel='.$_GET['b']);
  exit;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.