rewrite assistance

António P. P. Almeida appa at
Wed Nov 24 00:48:10 MSK 2010

On 23 Nov 2010 21h41 WET, nginx-forum at wrote:

> Hi all,
> I'm trying to add in a rewrite rule that will take this string and
> just do a redirect to / /preview.php?controllerName=channel&id=2
> Since the query string can vary, how would I craft my rewrite
> appropriately to do this?  I've tried a few variations of the
> following, but all it does is remove the "preview.php" portion of
> the string, leaving the "?controllerName=channel&id=2" rewrite
> ^/preview.php(.*) / permanent;

Note that your saying with your regex that I want a numeric capturing
group that can have *0* characters.

Try this:

^/preview.php(?:.*)$ / permanent;
Now you're saying match anything with a non-capturing group to the end
of the line.

--- appa

More information about the nginx mailing list