Welcome! Log In Create A New Profile


Re: Rewrite rules for Nginx

Sergey A. Osokin
November 12, 2022 09:20AM

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.

1. https://httpd.apache.org/docs/2.4/rewrite/flags.html
2. https://nginx.org/en/docs
3. https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite
4. http://nginx.org/en/docs/http/ngx_http_core_module.html#location

Hope that helps.

Sergey A. Osokin
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

Rewrite rules for Nginx

Bumb1ebe November 09, 2022 03:59PM

Re: Rewrite rules for Nginx

Sergey A. Osokin November 12, 2022 09:20AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 66
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready