I am trying to match a value in a cookie. The problem is, Apache makes the value url-encoded. So, if I do this:
RewriteCond %{HTTP_COOKIE} ^(.+)$ [NC]
It will capture this:
session%3DeXnR1oDL1Reb8Z3Gdgk7Sg%26account%3D2%3B
instead of this:
session=eXnR1oDL1Reb8Z3Gdgk7Sg&account=2
So there is no way to get the accoun开发者_JAVA百科t number to do this:
RewriteRule ^$ /accounts/%1/ [R=301,L]
Please help! I have looked everywhere on Google and stackoverflow and no one has addressed this issue. Thank you so much.
I never did find the answer -- BUT, I did find a work-around. For those having the same problem, here it is:
Separate your sub-cookie values using a character that will NOT get URL encoded. I used the dash character "-". e.g. "VAL1--VAL2".
Good luck!
Did you try using flag -> NE|noescape ?
By default, special characters, such as & and ?, for example, will be converted to their hexcode equivalent. Using the [NE] flag prevents that from happening.
RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]
The above example will redirect /anchor/xyz to /bigpage.html#xyz. Omitting the [NE] will result in the # being converted to its hexcode equivalent, %23, which will then result in a 404 Not Found error condition.
Source: http://httpd.apache.org/docs/2.3/rewrite/flags.html
精彩评论