Francis Daly
November 24, 2010 05:48AM
On Tue, Nov 23, 2010 at 11:42:38PM -0500, daveyfx wrote:

Hi there,

> > location = /preview.php {
> > rewrite ^ /? permanent;
> > }

> Spot on. That seems to have done the trick. Out of my own desire to
> learn, is there a way to do the same thing without using the location
> directive, and just merely using a rewrite statement?

Yes.

The manual says

"""
syntax: rewrite regex replacement flag
default: none
context: server, location, if
"""

The location{} block just says "only try this for some urls".

Within the server{} block, it would be "try this for all urls", and only
urls that match the regex would be rewritten.

So: the "rewrite" line that was almost working for you, with the extra
bit on the replacement part to suppress adding the query string, should
be what you want.

Good luck,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite assistance

daveyfx November 23, 2010 04:41PM

Re: rewrite assistance

António P. P. Almeida November 23, 2010 04:58PM

Re: rewrite assistance

daveyfx November 23, 2010 07:22PM

Re: rewrite assistance

Francis Daly November 23, 2010 07:32PM

Re: rewrite assistance

daveyfx November 23, 2010 11:42PM

Re: rewrite assistance

Francis Daly November 24, 2010 05:48AM

Re: rewrite assistance

Igor Sysoev November 24, 2010 06:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 142
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready