Rewrite rules for Nginx

Sergey A. Osokin osa at
Sat Nov 12 14:18:54 UTC 2022


hope you're doing well.

On Wed, Nov 09, 2022 at 03:59:22PM -0500, Bumb1ebe wrote:
> I am just moving my website from apache to nginx.
> Unfortunately none of the online converters helped me with dealing the
> htaccess migration to nginx rewrite rules.
> Can someone help me with rewriting the correctly please?
> RewriteRule ^news/(.*)/([0-9]+)\/?$ home/read-news/$1/$2 [NC,L]

Here's the explanation about apache 2.4 flags for RewriteRules [1].
In a few words:
- NC means match in a case-insensitive manner;
- L means stop processing the rule set.

Then please take a look on NGINX documentation site [2].
The following link to the rewrite directive contains very good,
example, [3].  It's very closer to what you want to implement.

Also, please take a look on the location directive [4], it
helps understand how to route a request to a location.


Hope that helps.

Sergey A. Osokin

More information about the nginx mailing list