The rewrite directive is an NGINX configuration feature that changes the request URI while the server is still processing it. That can redirect a request to a different location block, alter path resolution, or change which variables are populated later in the request flow. In practice, it is used for URL normalization, redirects, and internal routing.
It matters in security because URI rewriting can influence downstream logic. A request that looks harmless at the front end may be transformed into a different path before access control, file mapping, or logging decisions are made. Attackers often look for rewrite rules combined with directives such as alias or request-derived variables, because those combinations can expose unsafe code paths or trigger parser bugs. Defenders should review rewrite rules carefully, test edge cases, and verify that rewritten URIs still land in the intended locations.


