Welcome to WebmasterWorld Guest from 54.147.10.72

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Is the NE (noescape) flag reqd for "?" and "&" in the substitution?

Confusion with the manual.

     

penders

12:11 am on Nov 15, 2013 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Under the NE (noescape) flag in the Apache mod_rewrite manual it states:

By default, special characters, such as & and ?, for example, will be converted to their hexcode equivalent. Using the NE flag prevents that from happening.

Source: [httpd.apache.org...]

However, in my experience (per-directory .htaccess files) the & and ? characters are not percent-encoded and the NE flag is not necessary in this case!? Is the manual wrong, or am I missing something? The following works OK for me:

RewriteRule ^pattern substitution?foo=1&bar=2 [R=301,L]


The example given in the manual uses a # (fragment identifier) and yes, this would normally be encoded, so the NE flag would be required in this instance. So, I agree with their example, but not with the statement before it and it's bugging me!?

lucy24

1:58 am on Nov 15, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]

How 'bout the R instead of R=301 and the lack of full protocol-plus-domain in target? ;) An awful lot of Apache docs seem to involve "do as we say, not as we do".

The significant thing about # is that it has to be recognized by the browser in that form. If the browser gets a redirect response containing %23 it thinks that's just part of the URL it was supposed to ask for.

:: detour to test site ::

One place it can make a difference is if the query string contains literal question marks. Without [NE], all question marks after the first one (the query-string delimiter) turn into %3f. Frankly I can't figure out how to force escaping of & and = though. Putting = or & into the path-- with or without [NE] makes no difference-- has interesting consequences.

... and that's why people have test sites. You need to be able to play around without fear of making the server explode. Admittedly it would have been better if I kept careful notes so I could match browser's address bar with logged requests.

penders

11:07 pm on Nov 15, 2013 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Without [NE], all question marks after the first one (the query-string delimiter) turn into %3f


Thanks for the clarification / info. I hadn't realised that subsequent question marks, after the first one, are in fact encoded.

I linked to the 2.2 docs above, but the 2.4 docs state the same.

lucy24

1:54 am on Nov 16, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



I didn't know either until I played around on the test site :) The [NE] flag doesn't seem to affect & or = even if you have improbable sequences like ?& or ==.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month