homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Is the NE (noescape) flag reqd for "?" and "&" in the substitution?
Confusion with the manual.

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

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: https://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_ne

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!?



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

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.


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

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.


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

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 ==.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved