Trying to change a URL to have ampersands & is usually straight forward, you use %26.

However , throw in apahe mod_rewrite and PHP and things get a bit more complicated. Using the example – Books Forms & Pads – its URL encoded as:

books-forms-%26-pads

Apache will rewrite the url and PHP will pick up the ampersand as another variable. So assuming the variable was originally id it becomes:

array(2) { [“id”]=> string(12) “books-forms-” [“-pads”]=> string(0) “” }   Note the -pads as a blank variable.

Using the B flag in the rewrite , this get apache to escape and voila – PHP gets it all as a single variable.

array(1) { [“id”]=> string(18) “books-forms-&-pads” }

http://httpd.apache.org/docs/current/rewrite/flags.html#flag_b

Justin Taylor

Justin's path into design and marketing has been anything but conventional. A random selection of career decisions saw him designing rave flyers, t-shirts and (although refusing to divulge his stage name) he allegedly did a summer stint in Gt Yarmouth as a magician before finally settling on a career in marketing.