Rewrite with permanent and last

Is it possible to rewrite URL with HTTP 301 and make that last rule in
current ruleset? For example, in apache one can use flags “[R=301,L]” ,
but
how can one do it in nginx? I tried using following, but it returned
syntax
error:

Config: rewrite /members /users permanent last;

Error: nginx: [emerg] invalid number of arguments in “return” directive
in
/etc/nginx/nginx.conf:60

Any help?

On Wed, Nov 19, 2014 at 02:37:11PM -0800, neubyr wrote:

Hi there,

Is it possible to rewrite URL with HTTP 301 and make that last rule in
current ruleset?

Is that not what the flag “permanent” does?

http://nginx.org/r/rewrite

If not, can you show the config snippet, the request you make, and the
response you get instead of the response you expect?

f

Francis D. [email protected]

On Wed, Nov 19, 2014 at 2:44 PM, Francis D. [email protected]
wrote:

If not, can you show the config snippet, the request you make, and the
response you get instead of the response you expect?

Thanks for the reply Francis. May be permanent 301 redirect also implies
last, but I couldn’t find that in documentation. I don’t have any config
to
share as I am just exploring options and that’s the only rule I have (so
it
doesn’t matter right now but I may need it in future).

N

On Thu, Nov 20, 2014 at 2:15 PM, mex [email protected] wrote:

nginx has a last flag too:

Module ngx_http_rewrite_module

Yes, I was trying to use it along with permanent and that doesn’t work.
May
be ‘permanent’ implies ‘last’ as well.

  • N

nginx has a last flag too:

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

Posted at Nginx Forum:

On Thu, Nov 20, 2014 at 02:22:48PM -0800, neubyr wrote:

On Thu, Nov 20, 2014 at 2:15 PM, mex [email protected] wrote:

Hi there,

nginx has a last flag too:

Module ngx_http_rewrite_module

Yes, I was trying to use it along with permanent and that doesn’t work. May
be ‘permanent’ implies ‘last’ as well.

The nginx ‘permanent’ flag does not imply the nginx ‘last’ flag.

How (and whether) they might map to apache flags is a separate question.

If you want in nginx to complete the processing of a request with a HTTP
301 response, you can “rewrite … permanent” or “return 301 …”.

(“”“the processing stops and the redirect is returned to a client.”“”)

f

Francis D. [email protected]

As what you imply is not stated in the documentation, I would say you
are
mistaken.

If you need help, and as requested sooner, some configuration snippet(s)
might be more than helpful…

B. R.