Reputation: 11
I am trying to allow '&' in my mod_rewrite. at the moment i am using
RewriteRule ^([-a-zA-Z0-9_'_-]+)$
I tried adding:
RewriteRule ^([-a-zA-Z0-9_'_-_&]+)$
to allow ampersand, yet i know it is most likey wrong. can anyone direct me in the right direction for the correct regex layout.
Upvotes: 1
Views: 415
Reputation: 10537
You also must escape the hyphen because it indicates range for matching inside square brackets (it doesn't fail because you included it last but in other cases it would have like in OP).
Proper escaping of hyphen:
^([a-zA-Z0-9'&_\-]+)$
this would fail: ^([a-zA-Z0-9'_-&]+)$
this would not: ^([a-zA-Z0-9'_\-&]+)$
(i would have commented but my rep is not high enough)
Upvotes: 1