March 22, 2021 0 Comments

Last Updated on April 19, 2021 by amitoverflow1

NE flag htaccess
In this article we will learn about mod-rewrite NEflag. What this flag is used for and why we should use it all these frequently asked questions are answered in this article.
NE stands for NoEscape
We use this flag in RewriteRule to tell the engine not to escape special characters like # , & .. in URLs.

Here is an example of how mod-rewrite works without NE flag :

RewriteEngine on
RewriteRule ^foobar$ https://example.com/#foobar [R,L]

The rule above will redirect /foobar to https://example.com/%23foobar
As you can see the redirected URL path has changed to %23foobar . The # changed to its hexadecimal value%23 .This is because the rewrite engine converts special characters in redirected URL to their hex code. The characters are escaped by default if NE flag is not present in RewriteRule.
RewriteRule example with NE :

RewriteEngine on
RewriteRule ^foobar$ https://example.com/#foobar [NE,L,R]

The rule above does the redirection of the URL perfectly fine. This doesn’t change # to %23 as we used NE flag that tells server not to do so.

Leave a Reply

Your email address will not be published. Required fields are marked *