Mod_rewrite NE flag - When is it helpful to encode special chars in the URL?

While I agree that in some cases it is good to have this flag NE but it CANNOT always be used blindly with RewriteRule.

While I agree that in some cases it is good to have this flag NE but it CANNOT always be used blindly with RewriteRule. Let's says you want to pass in a query parameter with some special characters like %, $, ; etc to your code and you have NE flag enabled then your code might get unexpected or corrupt values. Let me show an example here.

Consider this is your . Htaccess file RewriteEngine on Options +FollowSymlinks -MultiViews RewriteCond %{QUERY_STRING}! ^done=1$ RewriteCond %{QUERY_STRING} ^var=.

*$ RewriteRule ^(.*)$ /$1? Done=1 NE,R,QSA,L And this is a 1 liner . Php file test.

Php: Now a URL of this type http://localhost/test. Php? Var=foo%bar will print following: string(5) "fooºr" However if you remove NE flag from rule above thus making it: RewriteRule ^(.*)$ /$1?

Done=1 R,QSA,L Now if you go to same URL http://localhost/test. Php? Var=foo%bar it prints CORRECTLY: string(7) "foo%bar" You can see how removal of NE (no escape) flag made it possible for your code to accept correct query parameters with special characters.

I think this example shows actually the opposite. Removing NE is good only for code poorly written by someone who does not even know that query parameter must always be url-encoded. The url you wrote should have been entered like this ...?var=foo%25bar.

Whoever enters an url with query parameters that are not url encoded deserves to get back stuff like fooºr. – Marco Demaio Apr 8 '11 at 9:15 I don't think your example proves a case for not using the NE flag. Maybe I'm missing something, but if I were to use your test.

Php, along with the example URL, but without using any rewrite rules at all, the generated page returns fooºr. Because of that, I don't think the "corruption" problem is due to excluding the NE from mod_rewrite. I am interested to see more examples though, ones that prove the case for not using NE.My general confusion is: why would you want mod_rewrite to play around with the URL encoding anyway?

– Vahid Pazirandeh Apr 19 '11 at 1:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions