Forum Moderators: phranque
That doesn't seem to work for me.
Maybe there's a more elegant solution to my overall problem. I have some fields in my db that must have an ampersand in them (i.e. M&M candies). I can't include them in my url because what follows the & is treated as a new variable in my query. Putting it in encoded form is ugly and non-intuitive. So I replace & with + in the url. Now I can't get the regex to recognize a literal +.
Is there a better way?
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([a-z\-]+)/(([a-z\-]¦%2b)+)\ HTTP/ [NC]
RewriteRule ^([a-z\-]+)/(.+)$ product.php?cat=%1&name=%2 [NC,NE,L]
Replace the broken pipe "¦" character with a solid pipe before use; Posting on this board modifies pipe characters.
THE_REQUEST is the entire request line sent by the browser, e.g.:
GET /candy/M+M-candies HTTP/1.1
You may also find it useful to change the RewriteRule temporarily to do an external redirect, so that you can see the results in your browser address bar; This often makes debugging these hex-encoding problems easier to deal with.
Jim
In query strings I think spaces can get translated into plus signs or %20 , so perhaps the webserver is translating the plus back to a space first. In which case try using an underscore or something instead of the plus.
uncle_bob,
You might be right. My main problem is I want a symbol which means 'and'. My options would be & or +. Maybe I should translate it to '-and-' even though a user would probably guess an url with '&' since it is the proper name.
I'll try to investigate more. Thanks for the tips and solutions.
4